Link to home
Start Free TrialLog in
Avatar of Joseph LaFlex
Joseph LaFlexFlag for United States of America

asked on

Using the DATEADD function with a Date Function for the Date

I am trying to run a script in SQL Anywhere 11 to update records based on activity that occured 3 days ago with the DATEADD function.

I am using it as follows:

DATEADD(day, -3, NOW())

Although it runs the script without any reported errors, it doesn't update the records.

If I use the following:

DATEADD(day, -3, '2012-05-23')

It updates the record correctly.

I've tried "GETDATE" with no luck either.

What can I use to replace an actual date for this script?
Avatar of Joe Woodhouse
Joe Woodhouse

Can you show us the actual UPDATE statement? You can change table and column names but it's helpful to see what's actually being run.
Avatar of Joseph LaFlex


UPDATE "DBA"."staffing_tbl" SET staffing_benign_si = 'N', wstat_no_in = 162 WHERE wSTAT_NO_IN = 86 and staffing_benign_si = 'Y' AND staffing_calendar_da = DATEADD(day, -3, NOW())
Avatar of alpmoon
Flag of Australia image

Link to home
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thanks, I got it working with your help.  It through an error but I found it was related to the style.  It need 120 not 101

convert(char(10), getdate(), 120)