Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 60
  • Last Modified:

Need help with a query

Hi Experts,

I want to get the date in  'mmddyyyy'  format  the CURRENT_TIMESTAMP . I have an insert statement. The date '08042016' should come from the CURRENT_TIMESTAMP .

Thanks in advance.

INSERT INTO LOGINDETAILS
            ( UserID,              
            StdTimeIn,
                TodaysDate    
          )
     VALUES
                ( 1,                                    
                  CURRENT_TIMESTAMP,
                  '08042016'                        
          )
0
RadhaKrishnaKiJaya
Asked:
RadhaKrishnaKiJaya
  • 2
1 Solution
 
vvkCommented:
using convert function with style 12 shall give format you want, something like convert(nvarchar(8),getdate(),12)
0
 
RadhaKrishnaKiJayaAuthor Commented:
Hi,

Thank you for your reply. With convert(nvarchar(8),getdate(),12)  I am getting '160804 '. but I need '08042016'

Thanks.
0
 
Dustin SaundersDirector of OperationsCommented:
Try:
SELECT FORMAT(GetDate(),'MMddyyyy')

Open in new window

0
 
RadhaKrishnaKiJayaAuthor Commented:
Thanks. It worked!!
0

Featured Post

NFR key for Veeam Backup for Microsoft Office 365

Veeam is happy to provide a free NFR license (for 1 year, up to 10 users). This license allows for the non‑production use of Veeam Backup for Microsoft Office 365 in your home lab without any feature limitations.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now