This discussion is archived
2 Replies Latest reply: Aug 23, 2012 11:19 AM by Paul Fowler

# TemporalOncePerYear and TemporalOncePerQuarter

Currently Being Moderated
I am trying to code the equivalent of TemporalOncePerYear() and TemporalOncePerQuarter(), so I can determine if we are at a yearly or quarterly anniversary.

If I know what the current temporal date is, then I can extract the year, month, day and do the math... However creating the current temporal date in MY way is a CPU hog. My way is the bad way.:

the current temporal date = AddDays(the issue date, TemporalDaysSince(the issue date, AddDays(the maturity date,1)))
the current temporal year = ExtractYear(the current temporal date)
the current temporal month = ExtractMonth(the current temporal date)
the current temporal day = ExtractDay(the current temporal date)

Alternatively, I can use the TemporalOn() to create functions like TemporalOncePerYear(), and this performs much better, but UGLY code. Also, I would expect a bug when the issue date is on the 31st and I go to create dates in months like February. It is just ugly to write and test. See the sample code here:

The temporal date falls on the same day of the year as the issue date if

Also, my quarterly code is going to blow people's minds in the complexity.

Anyone have thoughts? Is there a simple way to find out what the current temporal date is so that I can extract the current temporal month and day? Is there a simple way to find out if future dates are falling on the yearly or quarterly anniversaries, since that is my real goal?
• ###### 1. Re: TemporalOncePerYear and TemporalOncePerQuarter
Currently Being Moderated
I think I found the answer on my own....

I was just doing "too much" with my first calculation of:

The temporal year matches the issue year if

To figure out if I am on a year anniversary, all I had to do was:

We are on the year anniversary if

Of course, I am still figuring out the quarterly math, but I will probably get there in time...

Thank you
• ###### 2. Re: TemporalOncePerYear and TemporalOncePerQuarter
Currently Being Moderated
For anyone interested, I found the quarterly dates by the formula:

(TemporalMonthsSince(the start date, the maturity date) \ 3) * 3

Basically, do integer division followed by a multiplication and I got my equivalent of TemporalOncePerQuarter.

#### Legend

• Correct Answers - 10 points