|
| |
|
|
rrnml
Posts: 197 Joined: 9/20/2004 Status: offline
|
Get yesterday's date using SQL - 7/20/2005 11:37:43
Can anyone tell me how to get yesterday's date in SQL. I thought it was sysdate - 1, but that doesn't seem to work.
|
|
|
|
BeTheBall
Posts: 6355 Joined: 6/21/2002 From: West Point Utah USA Status: offline
|
RE: Get yesterday's date using SQL - 7/20/2005 11:54:51
Is is getdate -1?
_____________________________
Duane Some people are like Slinkies . . . Not really good for anything . . . . . But they still bring a smile to your face when you push them down a flight of stairs.
|
|
|
|
BeTheBall
Posts: 6355 Joined: 6/21/2002 From: West Point Utah USA Status: offline
|
RE: Get yesterday's date using SQL - 7/20/2005 12:08:54
You may need to use the DateAdd function. Something like: DateAdd("d", -1, getdate)
_____________________________
Duane Some people are like Slinkies . . . Not really good for anything . . . . . But they still bring a smile to your face when you push them down a flight of stairs.
|
|
|
|
rrnml
Posts: 197 Joined: 9/20/2004 Status: offline
|
RE: Get yesterday's date using SQL - 7/20/2005 12:39:03
I tried your suggestion and I get an error that says... Microsoft Access ADO Error: Invalid parameter 1 specified for dateadd. When I run it, instead of "d", it forces @d in the code. Any ideas?
|
|
|
|
BeTheBall
Posts: 6355 Joined: 6/21/2002 From: West Point Utah USA Status: offline
|
RE: Get yesterday's date using SQL - 7/20/2005 13:00:35
quote:
Can anyone tell me how to get yesterday's date in SQL. Ahh. You threw me a curveball. You said "in SQL," but according to your error, you are using Access. So I guess you meant in the SQL statement. Try this instead: DateAdd('d', -1, date())
_____________________________
Duane Some people are like Slinkies . . . Not really good for anything . . . . . But they still bring a smile to your face when you push them down a flight of stairs.
|
|
|
|
rrnml
Posts: 197 Joined: 9/20/2004 Status: offline
|
RE: Get yesterday's date using SQL - 7/20/2005 18:51:07
Thanks for your help. We ended up using DATEADD(d, - 1, { fn CURDATE() }) Found it in the Transact SQL Scalar Functions for Expressions. My co-worker didn't explain that it was an SQL db with an Access adp for the front end. We're using this function in a stored procedure to automate it so we'll see if it works in the morning. If not, I'll be back. Thanks again.
|
|
New Messages |
No New Messages |
Hot Topic w/ New Messages |
Hot Topic w/o New Messages |
Locked w/ New Messages |
Locked w/o New Messages |
|
Post New Thread
Reply to Message
Post New Poll
Submit Vote
Delete My Own Post
Delete My Own Thread
Rate Posts
|
|
|