Date format in SQL Server

  • I have a date column that displays as "12/1/2011" in Access. I noticed that if I write a Select statement in Management Studio, I get no results when I use the "m/d/yyyy" format after a Where. What's the correct way to set a criteria on a date formatted column?

  • guerillaunit (1/19/2012)


    I have a date column that displays as "12/1/2011" in Access. I noticed that if I write a Select statement in Management Studio, I get no results when I use the "m/d/yyyy" format after a Where. What's the correct way to set a criteria on a date formatted column?

    SQL server also stores the time in a datetime field, and if you use equality in your select statement where clause, you'll need to match it exactly, including the time. You could try

    SELECT column FROM table WHERE datetimetypedcolumn >='12/1/2011' AND datetimetypedcolumn < '12/2/2011'

    If there are some time values in there.

    (Notice the columns and table names were made up, replace them with something that exists 😉

  • guerillaunit (1/19/2012)


    I have a date column that displays as "12/1/2011" in Access. I noticed that if I write a Select statement in Management Studio, I get no results when I use the "m/d/yyyy" format after a Where. What's the correct way to set a criteria on a date formatted column?

    Can you please post your exact statement?

    Jared
    CE - Microsoft

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

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