extraction of date using sql function

  • How to get only date part from the GETDATE() function in sql

  • You cant remove the time , since time is an integral part of a date time field.

    But you can set it to midnight

    SELECT DATEDIFF(DAY,0,@Date)

    Is that any help ?



    Clear Sky SQL
    My Blog[/url]

  • That might have been a lead-up to:

    SELECT DATEADD(DAY, (DATEDIFF(DAY, 0, CURRENT_TIMESTAMP)), 0)

    You can use the CONVERT function with a style parameter to format the result.

    You can also use CONVERT to remove the time part. Some people find that more intuitive, though it is slower.

    In SQL 2008, we have the DATE data type - which might be what you were looking for?

    Paul

Viewing 3 posts - 1 through 3 (of 3 total)

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