Find no of Days in Previous month

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • tasawer
    New Member
    • Aug 2009
    • 106

    Find no of Days in Previous month

    Hi,

    I need help to create an sql command to find no of days in the current month of calculation and no of days in the month previous to it.

    This code works for the current month, but only because mgmtstart is always 1st of the month.

    Code:
    DaysinMonth: DateDiff("d",[mgmtDateStart],DateSerial(Year([mgmtdatestart]),Month([mgmtdatestart])+1,1))
    your help is greatly appreciated.
  • yarbrough40
    Contributor
    • Jun 2009
    • 320

    #2
    I believe Access has a DateAdd() function. I think this is what you want.

    Comment

    • missinglinq
      Recognized Expert Specialist
      • Nov 2006
      • 3533

      #3
      DaysInPreviousM onth:Day(DateSe rial(Year(Date) , Month(Date), 0))

      Linq ;0)>

      Comment

      • NeoPa
        Recognized Expert Moderator MVP
        • Oct 2006
        • 32661

        #4
        And, by extension :
        Code:
        DaysInMonth: Day(DateSerial(Year(Date), Month(Date) + 1, 0))

        Comment

        Working...