Showing posts with label server. Show all posts
Showing posts with label server. Show all posts

Monday, September 9, 2013

SQL Server tips to convert UTC Long value to Human Readable date

To Convert millisecond UTC time value in log to SQL SERVER Date Time with millisecond:
DECLARE @UTC BIGINT
SET @UTC = 1348203320997 
SELECT DATEADD(MILLISECOND, @UTC % 1000, DATEADD(SECOND, @UTC / 1000, '19700101')) 
To extract month, year values from a date-time value in SQL SERVER:
select 
datepart(month,getdate()) -- integer (1,2,3...)
,datepart(year,getdate()) -- integer
,datename(month,getdate()) -- string ('September',...) 
In MySQL:
select MONTHNAME(FROM_UNIXTIME(1375437322612/1000))select MONTH(FROM_UNIXTIME(1375437322612/1000))select YEAR(FROM_UNIXTIME(1375437322612/1000))