Thursday, 15 March 2012

SQL Server Date Time Format



CONVERT function is used to change or convert the DateTime formats.By using convert function you can get only Date part or only Time part from the DateTime.





CONVERT Function Syntax: 

      CONVERT(data_type,expression,date Format style)



Format
Query
dd mon yy
select convert(varchar, getdate(), 6)
Mon dd, yy
select convert(varchar, getdate(), 7)
mon dd yyyy hh:miAM (or PM)
select convert(varchar, getdate(), 100)
mm/dd/yyyy
select convert(varchar, getdate(), 101)
yyyy.mm.dd
select convert(varchar, getdate(), 102)
dd/mm/yyyy
select convert(varchar, getdate(), 103)
dd.mm.yyyy
select convert(varchar, getdate(), 104)
dd-mm-yyyy
select convert(varchar, getdate(), 105)
dd mon yyyy
select convert(varchar, getdate(), 106)
Mon dd, yyyy
select convert(varchar, getdate(), 107)
hh:mm:ss
select convert(varchar, getdate(), 108)
Default + milliseconds mon dd yyyy hh:mi:ss:mmmAM (or PM)
select convert(varchar, getdate(), 109)
mm-dd-yyyy
select convert(varchar, getdate(), 110)
yyyy/mm/dd
select convert(varchar, getdate(), 111)
yyyymmdd
select convert(varchar, getdate(), 112)
hh:mi:ss:mmm(24h)
select convert(varchar, getdate(), 114

Friendly Learn Translate to Tamil

Smilely

Services

© 2014