Results 1 to 6 of 6
  1. #1
    Join Date
    Mar 2004
    Posts
    9

    Unanswered: date expression for query criteria

    Hello all

    I am trying to get a certain date from a query that is one month ago using this:

    DateAdd("m",-1,Date()) but nothing comes up

    I also wanted to get the future date six months from now would I modify the above and append it to the expression?

    Thanks

    Scott

  2. #2
    Join Date
    Oct 2003
    Location
    Roanoke, Va
    Posts
    445

    Re: date expression for query criteria

    Originally posted by cervesot
    Hello all

    I am trying to get a certain date from a query that is one month ago using this:

    DateAdd("m",-1,Date()) but nothing comes up

    I also wanted to get the future date six months from now would I modify the above and append it to the expression?

    Thanks

    Scott
    This works for me.

    SomeDate:DateAdd("m", (-1), Date)
    SomeOtherDate:DateAdd("m", 6, Date)
    Gregg


    DAO, ADO, SQL, Automation and anything else I can pick up.

  3. #3
    Join Date
    Mar 2004
    Posts
    9

    Re: date expression for query criteria

    Originally posted by basicmek
    This works for me.

    SomeDateateAdd("m", (-1), Date)
    SomeOtherDateateAdd("m", 6, Date)
    That did not work either

  4. #4
    Join Date
    Oct 2003
    Location
    Roanoke, Va
    Posts
    445

    Re: date expression for query criteria

    Originally posted by cervesot
    That did not work either
    Don't know what else to tell you.

    I used a message box in a code window to display the results and got what I expected.
    Gregg


    DAO, ADO, SQL, Automation and anything else I can pick up.

  5. #5
    Join Date
    Mar 2004
    Posts
    9

    Re: date expression for query criteria

    Originally posted by basicmek
    Don't know what else to tell you.

    I used a message box in a code window to display the results and got what I expected.
    I was trying to put the the AddDate function in the query criteria in design view.

  6. #6
    Join Date
    Oct 2003
    Location
    Roanoke, Va
    Posts
    445

    Re: date expression for query criteria

    Originally posted by cervesot
    I was trying to put the the AddDate function in the query criteria in design view.
    This is what the SQL view looked like when I did it. I had a table by the name of test in the window, obviously, but didn't use any of the fields from it.

    SELECT DateAdd("m",(-1),Date()) AS Yesterday, DateAdd("m",6,Date()) AS 6MonthsFromNow
    FROM test;
    Gregg


    DAO, ADO, SQL, Automation and anything else I can pick up.

Posting Permissions

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