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

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),‘-‘,),‘:’,),‘.’,),‘ ‘,)
       

Leave a Reply

Your email address will not be published. Required fields are marked *