2008 being a leap year is causing me a headache on a date calculation - any help welcomed.
I have a start date to which I need to add a year -1 day days and end with a new date exactly one day prior to the original start date e.g.
01/01/08 to 31/12/08
31/08/07 to 30/08/08
I have tried various Dateserial and DateAdd but get cannot get consistent results due to the leapyear.
Assume startdate=31/08/07
returns 31/08/08 (I want 30/08/08)
Assume startdate=01/03/07
Returns 29/02/08 which appears to be correct until you change txtStartdate to 02/03/07 and it still returns 29/02/08.
This is driving me nuts and must be a common problem but I cannot find any previous postings for it.
Happiness is...not getting what you want but wanting what you have already got
I have a start date to which I need to add a year -1 day days and end with a new date exactly one day prior to the original start date e.g.
01/01/08 to 31/12/08
31/08/07 to 30/08/08
I have tried various Dateserial and DateAdd but get cannot get consistent results due to the leapyear.
Assume startdate=31/08/07
Code:
Format(DateAdd("yyyy", 1, txtStartDate), "dd/mm/yy")
Assume startdate=01/03/07
Code:
Format(DateSerial(Year(txtStartDate)+1, Month(txtStartDate),1-1 ), "dd/mm/yy")
This is driving me nuts and must be a common problem but I cannot find any previous postings for it.
Happiness is...not getting what you want but wanting what you have already got