Skip to main content
Inspiring
March 12, 2013
Answered

How to access a certain date in SQL Server date/time field

  • March 12, 2013
  • 1 reply
  • 910 views

I have a field named job_date in a table in my SQL server 8 database.

The data type is datetime.

So the values for the fields look like this  2013-03-11 15:55:52.000.

How do I query this field to include only values from a certain date?

For example

<cfquery name="get_job_name" datasource="abc">

SELECT job_name  FROM job_info WHERE job_date= '03/12/2013'

</cfquery>

When I query the field now I get NO RECORDS.

Thats because the fields look like this  2013-03-11 15:55:52.000. instead of this '03/12/2013'

How do I access a certain date in SQL Server date/time field when its formatted like this 2013-03-11 15:55:52.000. ?

This topic has been closed for replies.
Correct answer Dan_Bracuk

where job_date >= TheDateYouWant

and job_date < TheDayAfterTheDateYouWant#

Also, the format is irrelevent.  The only time date formats matter is when you want to display them.

1 reply

Dan_BracukCorrect answer
Inspiring
March 12, 2013

where job_date >= TheDateYouWant

and job_date < TheDayAfterTheDateYouWant#

Also, the format is irrelevent.  The only time date formats matter is when you want to display them.