SQL Query: Date Conversion PDF Print E-mail
Written by Administrator   
Tuesday, 10 March 2015 14:27

SQL Query Date conversions

--          Standard Date(time)

CONVERT(varchar,Your_Date,100) 'Mmm dd yyyy hh:mmdp',

CONVERT(varchar,Your_Date,101) 'mm/dd/yyyy',

CONVERT(varchar,Your_Date,103) 'dd/mm/yyyy'

CONVERT(VARCHAR(8), Your_Date, 1) AS 'dd/mm/yy'

--

--  UTC stored dates to local dates

CONVERT(DATE, SWITCHOFFSET(CONVERT(datetimeoffset,UTC_Date), DATENAME(TzOffset, SYSDATETIMEOFFSET()))) AS LocalDate

CONVERT(TIME, SWITCHOFFSET(CONVERT(datetimeoffset,UTC_Date), DATENAME(TzOffset, SYSDATETIMEOFFSET()))) AS LoacalTime

--

 

Last Updated on Friday, 27 January 2017 11:17