Results 1 to 4 of 4
  1. #1
    Join Date
    Jan 2004
    Posts
    115

    Unanswered: First and last day of previous month

    I have 2 fields on a form FirstDay and LastDay
    On the form on load event I would like to have the default value for
    the fields the first and last day of previous month

    Thanks
    Tom

  2. #2
    Join Date
    Sep 2004
    Location
    Charlotte, NC
    Posts
    164
    Tom,

    When you say the first day of the previous month, are you looking for 12/1/04 or Wednesday if you were doing it today?

    TD

  3. #3
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    Provided Answers: 59
    I think you will have to write a VBA function for this
    first (calendar) day of the month should be easy using the month

    you will need to insert some validation code to handle year ends

    if you supplied the current date then the start of the month is...
    Code:
    datStartofMonth=cdate("01/" & month(now() & "/" & year(now))
    Code:
    if month(now())=12 then
      datEndofMonth=cdate("01/01/" & year(now)+1)-1
    else
      datEndofMonth=cdate("01/" & month(now())+1 & "/" & year(now))-1
    endif

  4. #4
    Join Date
    Jan 2004
    Location
    Aberdeen, Scotland
    Posts
    1,067
    You could also use something like this
    Code:
    Sub datestuff()
    
                MsgBox DateSerial(Year(Date), Month(Date) - 1, 1)
                MsgBox DateSerial(Year(Date), Month(Date), 0)
        
    End Sub
    Dave

Posting Permissions

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