Link to home
Start Free TrialLog in
Avatar of pdvsa
pdvsaFlag for United States of America

asked on

Date query help

Experts, I need to modify the below.  
IN plain english (notice the '-1' at the end of the strSQL.  BAsically I need to update if DueDate is #Date# - 1, which is yesteday.
    strSQL = "UPDATE TASKS Set DueDate = DateAdd('d', 1, DueDate) WHERE DueDate=#" & Date & "#" - 1

thanks...

Private Sub cmdAdd1Yesterday_Click()

        Dim strSQL As String
    strSQL = "UPDATE TASKS Set DueDate = DateAdd('d', 1, DueDate) WHERE DueDate=#" & Date & "#"
    CurrentDb.Execute strSQL, dbFailOnError
Avatar of mbizup
mbizup
Flag of Kazakhstan image

    strSQL = "UPDATE TASKS Set DueDate = DateAdd('d', 1, DueDate) WHERE DueDate=#" & Dateadd("d", -1, Date())  & "#"

Open in new window

strSQL = "UPDATE TASKS Set DueDate = DueDate+1 WHERE DueDate=Date()-1"
Avatar of pdvsa

ASKER

OK thank you.  

For either way, can I add another criteria at the end?:
can I add
        strSQL = "UPDATE TASKS Set DueDate = DateAdd('d', 1, DueDate) WHERE DueDate=#" & DateAdd("d", -1, Date) & "#" & [Tasks].[status] <> "Completed"
ASKER CERTIFIED SOLUTION
Avatar of mbizup
mbizup
Flag of Kazakhstan image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of pdvsa

ASKER

perfect.  Thank you.