• saidapurs (9/26/2012)


    Hi All,

    Using below conversion i am getting date only like 20120926 but my requirement is 201209261015 like hour & time

    convert(nvarchar(50),(GetDate()),112))

    Please help me to get my exact answer...

    Thanks & Regards

    Satish

    Style 112 excludes time, returning only date.

    See CONVERT in Books Online for more information.

    There is no value for Style which will return datetime in the format you require,

    you will have to use something like 120, then remove the unwanted characters.

    You don't need a double-byte character set to hold numbers.

    Match your variable to your data - '201209261015' is CHAR(12)

    “Write the query the simplest way. If through testing it becomes clear that the performance is inadequate, consider alternative query forms.” - Gail Shaw

    For fast, accurate and documented assistance in answering your questions, please read this article.
    Understanding and using APPLY, (I) and (II) Paul White
    Hidden RBAR: Triangular Joins / The "Numbers" or "Tally" Table: What it is and how it replaces a loop Jeff Moden