Solved

Date query help

Posted on 2013-01-08
5
161 Views
Last Modified: 2013-01-08
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
0
Comment
Question by:pdvsa
  • 2
  • 2
5 Comments
 
LVL 61

Expert Comment

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

Open in new window

0
 
LVL 77

Expert Comment

by:peter57r
ID: 38754667
strSQL = "UPDATE TASKS Set DueDate = DueDate+1 WHERE DueDate=Date()-1"
0
 

Author Comment

by:pdvsa
ID: 38754887
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"
0
 
LVL 61

Accepted Solution

by:
mbizup earned 500 total points
ID: 38754918
        strSQL = "UPDATE TASKS Set DueDate = DateAdd('d', 1, DueDate) WHERE DueDate=#" & DateAdd("d", -1, Date) & "# AND status <> 'Completed'"

Open in new window


Or using the simpler syntax that Pete suggested:


        strSQL = "UPDATE TASKS Set DueDate = DateAdd('d', 1, DueDate) WHERE  status <> 'Completed' AND DueDate= Date() -1"

Open in new window

0
 

Author Closing Comment

by:pdvsa
ID: 38755463
perfect.  Thank you.
0

Featured Post

Simplifying Server Workload Migrations

This use case outlines the migration challenges that organizations face and how the Acronis AnyData Engine supports physical-to-physical (P2P), physical-to-virtual (P2V), virtual to physical (V2P), and cross-virtual (V2V) migration scenarios to address these challenges.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

QuickBooks® has a great invoice interface that we were happy with for a while but that changed in 2001 through no fault of Intuit®. Our industry's unit names are dictated by RUS: the Rural Utilities Services division of USDA. Contracts contain un…
It’s been over a month into 2017, and there is already a sophisticated Gmail phishing email making it rounds. New techniques and tactics, have given hackers a way to authentically impersonate your contacts.How it Works The attack works by targeti…
In Microsoft Access, learn different ways of passing a string value within a string argument. Also learn what a “Type Mis-match” error is about.
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.

786 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question