Get yesterday's date using SQL (Full Version)

All Forums >> [Web Development] >> ASP and Database



Message


rrnml -> 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 -> RE: Get yesterday's date using SQL (7/20/2005 11:54:51)

Is is getdate -1?




BeTheBall -> 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)




rrnml -> 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 -> 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())




rrnml -> 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.




Page: [1]

Valid CSS!




Forum Software © ASPPlayground.NET Advanced Edition 2.4.5 ANSI
0.046875