Results 1 to 2 of 2
  1. #1
    Join Date
    May 2004

    Unanswered: Query range: Within prior Month's first and last day

    I have a query that I need to pull records added during the prior month. (The table stores date of each new record.) So I'd like for the user to NOT have to add a date range each month (more work and not goof proof) when he/she runs the query. Does anyone know the code I'd use in the query to set the range based on "between" the first and last days (including those dates) for the prior month? Sounds simple but...

  2. #2
    Join Date
    Apr 2004
    Derbyshire, UK
    Provided Answers: 2

    Query dates

    I am not sure if you want a worksheet function or a VB cide solution but for the worksheet use

    =EOMONTH(NOW(),-1) for the the end date (last day of previouse month)


    =EOMONTH(NOW(),-2)+1 for the start date; (first day of previous month)

    In code the following will do the same job

    Sub SetDates(ByRef dStart As Date, ByRef dEnd As Date)

    dEnd = DateAdd("d", -Day(Date), Date)

    dStart = DateAdd("d", -Day(dEnd), dEnd) + 1

    End Sub

    Hope this coveres it


Posting Permissions

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