Solved

Need help with a query

Posted on 2016-08-04
4
32 Views
Last Modified: 2016-08-04
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
Comment
Question by:RadhaKrishnaKiJaya
  • 2
4 Comments
 
LVL 4

Expert Comment

by:vvk
ID: 41742852
using convert function with style 12 shall give format you want, something like convert(nvarchar(8),getdate(),12)
0
 

Author Comment

by:RadhaKrishnaKiJaya
ID: 41742858
Hi,

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

Thanks.
0
 
LVL 12

Accepted Solution

by:
Dustin Saunders earned 500 total points
ID: 41742863
Try:
SELECT FORMAT(GetDate(),'MMddyyyy')

Open in new window

0
 

Author Closing Comment

by:RadhaKrishnaKiJaya
ID: 41742874
Thanks. It worked!!
0

Featured Post

Best Practices: Disaster Recovery Testing

Besides backup, any IT division should have a disaster recovery plan. You will find a few tips below relating to the development of such a plan and to what issues one should pay special attention in the course of backup planning.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I have a large data set and a SSIS package. How can I load this file in multi threading?
Preparing an email is something we should all take special care with – especially when the email is for somebody you may not know very well. The pressures of everyday working life stacked with a hectic office environment can make this a real challen…
In Microsoft Access, learn the trick to repeating sub-report headings at the top of each page. The problem with sub-reports and headings: Add a dummy group to the sub report using the expression =1: Set the “Repeat Section” property of the dummy…
With Microsoft Access, learn how to specify relationships between tables and set various options on the relationship. Add the tables: Create the relationship: Decide if you’re going to set referential integrity: Decide if you want cascade upda…

776 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question