Saturday, August 10, 2013

How to get the DDMMYYYYHHMMSSMMM and YYYYMMDDHHMMSSMMM date formats in SQL Server.


Below are the SQL statements by which we can get the required formats:
  • DDMMYYYYHHMMSSMMM format :
               SELECT REPLACE(CONVERT(VARCHAR(10), GETDATE(), 103),'/','') +    
     REPLACE
(CONVERT(VARCHAR(12), GETDATE(), 114) ,':','')
 

  • YYYYMMDDHHMMSSMMM format :
            SELECT REPLACE(REPLACE(REPLACE(REPLACE(CONVERT(VARCHAR, GETDATE(), 
    121),'-',''),':',''),'.',''),' ','')
       

1 comment:

  1. AnyConv is a good free file converter that supports lots of file formats. It's really easy to use. AnyConv

    ReplyDelete