SQL statement to get selected date - 1 day

Mark Harris
Mark Harris used Ask the Experts™
on
Hello,
I have a Sybase DB and I have a Query that has the following:
DATEFORMAT(CALENDAR_DATE, 'MM/DD/YYYY') AS CALENDAR_DATE_STR

The user will input a date at a command prompt like
01/01/2011 or 07/04/2011

What I need is to change the query so that it will actually select the day before whatever was input.
So if a user puts in
01/01/2011
The query will Select
12/31/2010

Or
07/04/2011
will get
07/03/2011

Thanks
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
You just need to use DATEADD:

DATEFORMAT(DATEADD(dd, -1, CALENDAR_DATE), 'MM/DD/YYYY') AS CALENDAR_DATE_STR

Commented:
try this...

dateadd(d,-1, yourdate)

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial