Problem:

You need to select data from a DateTime or Date field from a Microsoft SQL Server table.
 

Solution:

Use the following examples to select data from a table using a DateTime or Date field range for the selection criteria:
 
Note: The start time is 1 second past midnight, and the end time is 1 second before midnight to cover the entire day.
  • To select a single DateTime, use:

    select * from NameAddress where CreateDate >= '12/10/2003 00:00:01'  and CreateDate <= '12/10/2003 23:59:59)

  • To select multiple DateTimes, use:

    select * from NameAddress where CreateDate >= '12/1/2003 00:00:01'  and CreateDate <= '12/31/2003 23:59:59)

  • To select a single Date, use:

    select * from NameAddress where CreateDate >= '12/10/2003'  and CreateDate <= '12/10/2003 23:59:59)

  • To select multiple Dates, use:

    select * from NameAddress where CreateDate >= '12/1/2003'  and CreateDate <= '12/31/2003)


Still have questions? We can help. Submit a case to Technical Support.

Last Modified On: December 10, 2016