SQL Server Performance
  1. sneevand New Member

    by default datetime in sql stored as mm/dd/yyyy 12.36.54 am now i need only time part of it that is as 12:36 am

    thank you
  2. FrankKalis Moderator

    <pre id="code"><font face="courier" size="2" id="code"><br />SELECT CONVERT(CHAR(<img src='/community/emoticons/emotion-11.gif' alt='8)' />, GETDATE(), <img src='/community/emoticons/emotion-11.gif' alt='8)' /><br />SELECT CONVERT(CHAR(<img src='/community/emoticons/emotion-11.gif' alt='8)' />, GETDATE(), 10<img src='/community/emoticons/emotion-11.gif' alt='8)' /><br />SELECT RIGHT(STUFF(CONVERT(CHAR(22),GETDATE(),13),21,4,' '),9)<br /></font id="code"></pre id="code"><br />In case you also need milliseconds, do<br /><pre id="code"><font face="courier" size="2" id="code"><br />SELECT CONVERT(CHAR(12),GETDATE(),114)<br /></font id="code"></pre id="code"><br /><br />--<br />Frank Kalis<br />Microsoft SQL Server MVP<br /<a target="_blank" href=http://www.insidesql.de>http://www.insidesql.de</a><br />Ich unterstütze PASS Deutschland e.V. <a target="_blank" href=http://www.sqlpass.de>http://www.sqlpass.de</a>) <br />

Share This Page