Avatar of Joseph LaFlex
Joseph LaFlex
Flag 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?
Sybase Database

Avatar of undefined
Last Comment
Joseph LaFlex

8/22/2022 - Mon
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.
Joseph LaFlex

ASKER
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())
ASKER CERTIFIED SOLUTION
alpmoon

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
Joseph LaFlex

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

Joe
Experts Exchange is like having an extremely knowledgeable team sitting and waiting for your call. Couldn't do my job half as well as I do without it!
James Murphy