Solved

Need help with a query

Posted on 2016-08-04
4
27 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

Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

Question has a verified solution.

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

Slowly Changing Dimension Transformation component in data task flow is very useful for us to manage and control how data changes in SSIS.
This article shows gives you an overview on SQL Server 2016 row level security. You will also get to know the usages of row-level-security and how it works
Viewers will learn how to use the INSERT statement to insert data into their tables. It will also introduce the NULL statement, to show them what happens when no value is giving for any given column.
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

920 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now