• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 200
  • Last Modified:

Need the SQL to compare dates with no times

Hi,

I need to compare a date the time is null in the database.

sql += "WHERE Return_Time > {ts '2006-03-18 00:00:00'}";

I need to compare the date in an SQL query with a date column which has zeroes for the time.  But when I use that format in the string I get an SQL exception error.

Has anyone got an idea how to use correct SQL syntax to do this?  I only want to check the date, obviously, since the time is null anyway.

Thanks,
Bob

PS your expediency would be appreciated since I am debugging on the client's computer:)
0
ba272
Asked:
ba272
1 Solution
 
VovinECommented:
This link:
http://www.sql-server-helper.com/functions/get-date-only.aspx

solves your problem.

I personally like best third solution:
CAST(FLOOR(CAST(@pInputDate AS DECIMAL(12, 5))) AS DATETIME)
0
 
ba272Author Commented:
thanks.
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now