Solved

Date query help

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

U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Access Form - Button Format Issue 13 50
Microsoft Access 32-bit or 64-bit? 11 59
SUBFORM on ACCESS 2013 8 35
Access Data Retrieval 1 12
A simple tool to export all objects of two Access files as text and compare it with Meld, a free diff tool.
This article describes two methods for creating a combo box that can be used to add new items to the row source -- one for simple lookup tables, and one for a more complex row source where the new item needs data for several fields.
Familiarize people with the process of utilizing SQL Server views from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Access…
In Microsoft Access, learn the trick to repeating sub-report headings at the top of each page. The problem with sub-reports and headings: Add a dummy group to the sub report using the expression =1: Set the “Repeat Section” property of the dummy…

738 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