date conversion | SQL Server Performance Forums

SQL Server Performance Forum – Threads Archive

date conversion

Hello, guys. How do I convert the value ‘2001-01-11 01:00:00#%92 to look like 11.01.2001? Thanks.

select convert(varchar(10), getdate(), 101)<br /><br />You can read more about convert in BOL where you will find other "styles".<br /><br /><br />FROM BOL:<br />- 0 or 100 (*) Default mon dd yyyy hh:miAM (or PM) <br />1 101 USA mm/dd/yy <br />2 102 ANSI yy.mm.dd <br />3 103 British/French dd/mm/yy <br />4 104 German dd.mm.yy <br />5 105 Italian dd-mm-yy <br />6 106 – dd mon yy <br />7 107 – Mon dd, yy <br />8 108 – hh:mm<img src=’/community/emoticons/emotion-7.gif’ alt=’:s’ />s <br />- 9 or 109 (*) Default + milliseconds mon dd yyyy hh:mi<img src=’/community/emoticons/emotion-7.gif’ alt=’:s’ />s:mmmAM (or PM) <br />10 110 USA mm-dd-yy <br />11 111 JAPAN yy/mm/dd <br />12 112 ISO yymmdd <br />- 13 or 113 (*) Europe default + milliseconds dd mon yyyy hh:mm<img src=’/community/emoticons/emotion-7.gif’ alt=’:s’ />s:mmm(24h) <br />14 114 – hh:mi<img src=’/community/emoticons/emotion-7.gif’ alt=’:s’ />s:mmm(24h) <br />- 20 or 120 (*) ODBC canonical yyyy-mm-dd hh:mi<img src=’/community/emoticons/emotion-7.gif’ alt=’:s’ />s(24h) <br />- 21 or 121 (*) ODBC canonical (with milliseconds) yyyy-mm-dd hh:mi<img src=’/community/emoticons/emotion-7.gif’ alt=’:s’ />s.mmm(24h) <br />- 126(***) ISO8601 yyyy-mm-dd Thh:mm<img src=’/community/emoticons/emotion-7.gif’ alt=’:s’ />s:mmm(no spaces) <br />- 130* Kuwaiti dd mon yyyy hh:mi<img src=’/community/emoticons/emotion-7.gif’ alt=’:s’ />s:mmmAM <br />- 131* Kuwaiti dd/mm/yy hh:mi<img src=’/community/emoticons/emotion-7.gif’ alt=’:s’ />s:mmmAM <br />
SELECT REPLACE(CONVERT(Varchar(10),GetDate(),101),’/’,’.’)
Brett :cool:
]]>