# Welcome!

By registering with us, you'll be able to discuss, share and private message with other members of our community.

#### samintz

##### Scott Mintz
What is the easiest way to compute a date that is 10 years from today?

-Scott

ISO: %@eval[%_year + 10]-%_month-%_day
assuming you are not close enough to midnight of the last day of a month so the date might change between retrieving its various parts

ISO: %@eval[%_year + 10]-%_month-%_day
assuming you are not close enough to midnight of the last day of a month so the date might change between retrieving its various parts

But you'll need to check for leap days (today!) If today is a leap day, then ten years from today ain't.

Except that 02-29-2022 is not a valid date.

I basically used @makeage to give a magic number that represents 10 years.
Since @makeage[1/1/1601] returns 0, I figured 1/1/1611 would be 10 years.
Code:
``````So, 10 years from today is:
echo %@agedate[%@eval[%@makeage[%_date] + %@makeage[1/1/1611]]]``````

I basically used @makeage to give a magic number that represents 10 years. Since @makeage[1/1/1601] returns 0, I figured 1/1/1611 would be 10 years.
Code:
``````So, 10 years from today is:
echo %@agedate[%@eval[%@makeage[%_date] + %@makeage[1/1/1611]]]``````

So 10 years from May 23, 1970 would be:
Code:
``echo %@agedate[%@eval[%@makeage[1970-05-23] + %@makeage[1611-01-01]]]``

10 years could be 3652 days, or 3653 days, or even (very rarely) 3651 days.

So 10 years from May 23, 1970 would be:
Code:
``echo %@agedate[%@eval[%@makeage[1970-05-23] + %@makeage[1611-01-01]]]``

10 years could be 3652 days, or 3653 days, or even (very rarely) 3651 days.
I'm creating a digital certificate and I want the expiration date to be 10 years from today. I don't think a day plus or minus will matter much.

I think you should simply add 10 years to the "current" date, then add one *day* if the ending date is "29/feb" for a non-leap year (i.e.: simply replacing day and month with 01/mar).

13/11/1970 + 10 years is 13/11/1980.
29/02/2012 + 10 years is 01/03/2012.

I'm creating a digital certificate and I want the expiration date to be 10 years from today. I don't think a day plus or minus will matter much.
Just like children born today - when will their birthdays be in non-leap-years? The problem is not the day count; it is specifying a leap day in a non-leap-year.

%@eval[%_year+10][%if[%_month EQ 2 .and. %_day EQ 29,-03-01,-%_month%_day]

will make 10 years the same date if possible; if today is a leapday, makes it March 1st ten years hence. NOT TESTED!

What is the easiest way to compute a date that is 10 years from today?

Using the @yearadd function from the FedUtils8 plugin, I get the following;

Code:
``````echo %@yearadd[2012-02-29,10]
2/28/2022``````

Joe

10 years could be 3652 days, or 3653 days, or even (very rarely) 3651 days.
When I first read that I did a double-take, and even after thinking about it it took me a while. I guess that 3651 probably isn't worth worrying about since it hasn't happened for over a hundred years and won't for another 80. Obviously for Scott's certificate expiry example then using 3652 days would seem a decent compromise but if you desire an 'accurate' result then the only way to be sure is to use the 'add ten to the year' method and cater for the special case of 29th Feb.

An interesting diversion, thanks folks ;)

Replies
10
Views
1K
Replies
3
Views
916
Replies
2
Views
1K
Replies
0
Views
1K
Replies
2
Views
2K
Replies
12
Views
3K
Replies
1
Views
2K
Replies
9
Views
3K
Replies
1
Views
2K
Replies
7
Views
2K
Replies
5
Views
4K