Solved

Date query help

Posted on 2013-01-08
5
157 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

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

Suggested Solutions

A simple tool to export all objects of two Access files as text and compare it with Meld, a free diff tool.
Describes a method of obtaining an object variable to an already running instance of Microsoft Access so that it can be controlled via automation.
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

707 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now