Results 1 to 5 of 5
  1. #1
    Join Date
    Feb 2006
    Posts
    38

    Unanswered: About Function:GETDATE()

    Hello,
    I use
    Code:
    SELECT CONVERT(VARCHAR(30),GETDATE(),105)
    and get the now data
    Code:
    25-04-2006
    ,
    but if i want to get the data format is
    Code:
    2006-04-25
    How?
    Thank you!

  2. #2
    Join Date
    Feb 2004
    Location
    One Flump in One Place
    Posts
    14,912
    Hi

    There is a more efficient way of stripping the time portion off however it doesn't quite match your format. Second function is perhaps more what you are after.
    Code:
    SElECT DATEADD(DAY, DATEDIFF(DAY, 0, GETDATE()), 0)
     
    SELECT CONVERT(CHAR(10),GETDATE(),120)
    HTH
    Testimonial:
    pootle flump
    ur codings are working excelent.

  3. #3
    Join Date
    Feb 2006
    Posts
    38
    the result is right! but
    Code:
     
    SELECT CONVERT(CHAR(10),GETDATE(),120)
    is it insecurely?

  4. #4
    Join Date
    Feb 2004
    Location
    One Flump in One Place
    Posts
    14,912
    Um.... I don't know. What do you mean by "insecurely"?

    BTW - you can look up the constants in the BOL entry for CAST and CONVERT too.
    Testimonial:
    pootle flump
    ur codings are working excelent.

  5. #5
    Join Date
    Feb 2006
    Posts
    38
    ok,thank you!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •