Results 1 to 3 of 3

Thread: Calculate due date

  1. #1
    Join Date
    Jan 2003
    Posts
    2

    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)

  2. #2
    Join Date
    Nov 2002
    Location
    DE
    Posts
    246
    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)

  3. #3
    Join Date
    Jan 2003
    Posts
    2
    Thank you so much!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •