MS SQL Milliseconds since 1970 |
|
|
|
Written by Zack MIlls
|
Friday, 09 July 2010 07:49 |
CAST(DATEDIFF(s, '1970-01-01 00:00:00.000', A.DateTimeModified) AS BIGINT) * 1000 + DATEPART(ms, A.DateTimeStamp) AS 'MS Since 1970',
- CAST(DATEDIFF(s, '1970-01-01 00:00:00.000', @InputDate) AS BIGINT) * 1000 + DATEPART(ms, @InputDate) AS 'MS Since 1970',
- convert(bigint,datediff(S,convert(datetime,'01/01/1970 00:00:000'),A.DateTimeModified)) *1000 AS 'MS Since 1970'
http://www.databasejournal.com/features/mssql/article.php/3820771/Formatted-date-in-SQL-Server-2008.htm
DATEDIFF (datepart ,startdate ,enddate )
- datepart
-
Is the part of startdate and enddate that specifies the type of boundary crossed. The following table lists all valid datepart arguments. User-defined variable equivalents are not valid.
datepart
|
Abbreviations
|
year
|
yy, yyyy
|
quarter
|
qq, q
|
month
|
mm, m
|
dayofyear
|
dy, y
|
day
|
dd, d
|
week
|
wk, ww
|
hour
|
hh
|
minute
|
mi, n
|
second
|
ss, s
|
millisecond
|
ms
|
microsecond
|
mcs
|
nanosecond
|
ns
|
-
- startdate
-
Is an expression that can be resolved to a time, date, smalldatetime, datetime, datetime2, or datetimeoffset value. date can be an expression, column expression, user-defined variable or string literal. startdate is subtracted from enddate.
To avoid ambiguity, use four-digit years. For information about two digits years, see two digit year cutoff Option.
- enddate
-
See startdate.
|