DateOf getdate()

  • How can I obtain a date part of the function getdate ? or any datetime value.

    For Example:

    If i have a value: "30/11/2009 12:32:33", I need to obtain the result: 30/11/2009

    Thanks

  • Select convert(varchar(10), getdate(), 103)

    ---------------------------------------------------------------------------------

  • Thanks for ansuwer me.

    And If I need to obtain the time of the getdate ?

    How can I do that?

  • You could try looking up CONVERT in BOL (Books Online).

    select convert(varchar(10), getdate(), 108)

  • Easy and it depends in what format you want. For the format you've shown try this,

    Select RIGHT(convert(varchar(20), getdate(), 120), 8)

    Edit:Just saw Lynn's post. Thats elegant take that.

    ---------------------------------------------------------------------------------

Viewing 5 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic. Login to reply