ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Subtract 1 year from todays date (https://www.excelbanter.com/excel-programming/349675-subtract-1-year-todays-date.html)

Nigel

Subtract 1 year from todays date
 
I have looked and I know it must be eady but I want to subtract 1 year from
todays date in code, so I tried date-1 year but to no avail, I can use
date-365 but I would like it to automatically take into account leap years

Thanks

new.microsoft.com

Subtract 1 year from todays date
 
This formular in code may work

1_yr_before = DateSerial(Year(Now()) - 1, Month(Now()), Day(Now()))

yc
"Nigel" wrote in message
...
I have looked and I know it must be eady but I want to subtract 1 year from
todays date in code, so I tried date-1 year but to no avail, I can use
date-365 but I would like it to automatically take into account leap years

Thanks




bpeltzer

Subtract 1 year from todays date
 
=date(year(date())-1,month(date()),day(date())) will take today's month/day
and the prior year. I'm not sure what you'd get on Feb 29 ;-).

"Nigel" wrote:

I have looked and I know it must be eady but I want to subtract 1 year from
todays date in code, so I tried date-1 year but to no avail, I can use
date-365 but I would like it to automatically take into account leap years

Thanks


voodooJoe

Subtract 1 year from todays date
 
using a formula: =EDATE(TODAY(),-12)
using VBA: dateadd("yyyy",-1,date)

cheers - voodooJoe

"Nigel" wrote in message
...
I have looked and I know it must be eady but I want to subtract 1 year from
todays date in code, so I tried date-1 year but to no avail, I can use
date-365 but I would like it to automatically take into account leap years

Thanks





All times are GMT +1. The time now is 09:39 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com