Perpetual Date Change In a Query

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Proaccesspro
    New Member
    • Apr 2007
    • 132

    Perpetual Date Change In a Query

    I run a report EVERY 2 weeks. I'm using a query as the source of the report. The report is Date driven. Is there a way to implement in the query itself a method to retrieve the Current month? In other words, I generally run the reports from the 1-15th of the month and the 16-31. Instead of manually changing the date parameter in the query from BETWEEN 1/1/2008 - 1/15/2008 TO 1/16/2008 - 1/31/2008, could this be automated?? Also, could the same thing be done for the month and year for that matter?
  • Scott Price
    Recognized Expert Top Contributor
    • Jul 2007
    • 1384

    #2
    You'll want to investigate the DatePart() function. For example:

    Code:
    DatePart("m", Date)
    will return 2, as the current month of the current date.

    Opening the vba code window in Access, (Alt+F11) and typing this into the immediate window (Ctl+G) then pressing F1 will open the topic specific help file which gives you all (or the majority) of the things you can do with this function.

    Regards,
    Scott

    Comment

    • NeoPa
      Recognized Expert Moderator MVP
      • Oct 2006
      • 32656

      #3
      There are also Day(), Month() & Year() functions available which return the numerical equivalents of each component.

      Comment

      • FishVal
        Recognized Expert Specialist
        • Jun 2007
        • 2656

        #4
        Also, you may find useful DateSerial() function which combines year, month and day numerical variables back to date variable.

        Regards.
        Fish

        Comment

        Working...