Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Rhinorhino on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

getdate() problems 1

Status
Not open for further replies.

durug

Technical User
Joined
Mar 22, 2002
Messages
335
Location
CA
Hi everybody!

I have this where statement in my select
where getdate() < = start_date
if getdate is the same date as start_date then this condition is not true because start_date is returned like this 2002-07-27 00:00:00.000 and getdate() is equal with
2002-07-27 05:25:00.000

How can I fix this problem. One way is to add to start_date 23 hours and 59 minutes. But what is the syntax for this?

Or is there other way so solve this?

Thanks a lot,
durug
 
if

datediff( day, start_date, getdate() ) > 1
^
can also use any date part
then you have a greater than 1 day difference between your start date and now

hope this helps mike griffith
----------------------------
mgriffith@lauren.com
mdg12@po.cwru.edu
 
you could also use the datepart(day, date_expression), datepart(month, date_expression), datepart(year, date_expression) and compare getdate() and your date, substituting each in for date_expression
or you could use the dateadd(hour, 23, date_expression) function if you wanted to do it the way you suggested

there's all kinds of neat date functinos

i have a listing of all sorts of useful functions that i printed out from


check them out [although they did leave some useful string functions out like replace(char_to_find, which_string, char_to_replace_with) and substring(string, start_index, stop_index) out]

mike griffith
----------------------------
mgriffith@lauren.com
mdg12@po.cwru.edu
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top