?
Solved

Date query help

Posted on 2013-01-08
5
Medium Priority
?
172 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 2000 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 SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

Question has a verified solution.

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

AutoNumbers should increment automatically, without duplicates.  But sometimes something goes wrong, and the next AutoNumber value is a duplicate.  This article shows how to recover from this problem.
Instead of error trapping or hard-coding for non-updateable fields when using QODBC, let VBA automatically disable them when forms open. This way, users can view but not change the data. Part 1 explained how to use schema tables to do this. Part 2 h…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
With Microsoft Access, learn how to specify relationships between tables and set various options on the relationship. Add the tables: Create the relationship: Decide if you’re going to set referential integrity: Decide if you want cascade upda…

719 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