Date Calculations

Results 1 to 2 of 2

Thread: Date Calculations

  1. #1
    Genny Guest

    Default Date Calculations

    I need to auto calculate a complete date value for the 1st day of the the previous month. For example, I want to convert 3/5/2000 to 2/1/2000 or convert 1/19/2000 to 12/1/1999.<BR><BR>I tried using x=DateSerial(Year(Date),Month(Date)-1,1) but that won&#039t work with my second example (moving from January to December of the previous year).<BR><BR>What&#039s the easiest way to do this?<BR><BR>Thanks,<BR><BR>Genny

  2. #2
    KPW Guest

    Default RE: Date Calculations

    What about using the DateSerial (as you have) but, if the month is 1 (before using DateSerial) then just assume that the previous month is 12 and the subtract 1 from the year?<BR><BR>If Month(Date) = 1 then<BR>x = "12/1/1999"<BR>Else<BR>x = DateSerial(Year(Date),Month(Date)-1,1)<BR>End If<BR><BR>HTH

Posting Permissions

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