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'                        
          )
RadhaKrishnaKiJayaAsked:
Who is Participating?
 
Dustin SaundersConnect With a Mentor Director of OperationsCommented:
Try:
SELECT FORMAT(GetDate(),'MMddyyyy')

Open in new window

0
 
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
 
RadhaKrishnaKiJayaAuthor Commented:
Thanks. It worked!!
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.