且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

当日期表示为UNIX时间戳时,在Oracle中选择两个日期之间的最小差异

更新时间:2022-12-09 17:42:48

好吧,Unix时间戳表示为自1970年1月1日以来的秒数,因此,如果您从另一个中减去一个,则会得到以秒为单位的差.那么,天数的差异就是除以一天中的秒数即可.

Well, Unix timestamps are expressed as a number of seconds since 01 Jan 1970, so if you subtract one from the other you get the difference in seconds. The difference in days is then simply a matter of dividing by the number of seconds in a day:

(date_modified - date_submitted) / (24*60*60)

(date_modified - date_submitted) / 86400