-
Calculate due date
I have a field DueDate in reports table.
I need to write a query that will return all records with a due date that falls in the next month from now.
So, if it is Jan. 14, I want all records that are due in the month of Feb.
In the criteria of the DueDate field, would I have:
=Datepart(“m”,Date())+1)
-
Hi!
if you want to calculate the following month use DATEADD:
DatePart("m",DATEADD ("m",1, Date()))
You should also respect the year of your due date. Otherwise you will get back all records due in Feb of any year!
So final condition might look follows:
WHERE
DATEPART ("yyyy",DATEADD ("m",1,Date()))
= DATEPART ("yyyy",due_date)
AND
DATEPART ("m",DATEADD ("m",1,Date()))
= DATEPART ("m",due_date)
-
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
|