SQL Date Format

Posted on 2009-12-22
Last Modified: 2012-05-08
I need to store GetDate() as '19000101213924'  As [nvarchar](50)

Question by:MBoy
    LVL 75

    Accepted Solution

    select CONVERT(varchar, getdate(), 112 ) + REPLACE(CONVERT(varchar, getdate(),108),':','')
    LVL 75

    Expert Comment

    by:Aneesh Retnakaran
    not sure what exactl the logic behind that, to be frnak thats not a good idea, why dont you store it as datetime
    LVL 40

    Assisted Solution

    check this.

    SELECT replace(replace(replace(CONVERT(varchar(50),GETDATE(),120),':',''),'-',''),' ','')
    LVL 3

    Author Comment

    why dont you store it as datetime - I agree but the communications check routines dictate

    Thanks for your help!

    Featured Post

    Gigs: Get Your Project Delivered by an Expert

    Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

    Join & Write a Comment

    Suggested Solutions

    Audit has been really one of the more interesting, most useful, yet difficult to maintain topics in the history of SQL Server. In earlier versions of SQL people had very few options for auditing in SQL Server. It typically meant using SQL Trace …
         When we have to pass multiple rows of data to SQL Server, the developers either have to send one row at a time or come up with other workarounds to meet requirements like using XML to pass data, which is complex and tedious to use. There is a …
    Hi everyone! This is Experts Exchange customer support.  This quick video will show you how to change your primary email address.  If you have any questions, then please Write a Comment below!
    Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…

    746 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

    16 Experts available now in Live!

    Get 1:1 Help Now