Converting Getdate to smalldate

  • i am querying a date field, it is a smalldate, not null field. The date format in this field is below, i have tried different converts, cast to get date converted to this format but nothing is working. What i tried returns the date but in the time returns the actual time, the field i am querying the time for all records is zeros.

    date format in field

    210-08-03 00:00:00

    What i tried

    SELECT CONVERT(datetime, CONVERT(varchar, GETDATE(), 110))

    SELECT CAST(GETDATE() AS SMALLDATETIME)

  • There are several ways that you can accomplish this. Probably the most straightforward is the following.

    SELECT CAST(CAST(GETDATE() AS DATE) AS SMALLDATETIME)

    Drew

    J. Drew Allen
    Business Intelligence Analyst
    Philadelphia, PA

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

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