Weeks to End of Fiscal Year

Does anyone know of a way to get the # of weeks to the end of a company’s Fiscal Year. The WeeksToY variable doesn’t actually do this (instead it is the number of weeks until the Annual Financials are released).

Ostensibly this could be accomplished as follows:

((PeriodDateA + 365) - Today) / 5

However, there is not a good way to work with serial date functions in P123. Moreover, there is no “today()” function in P123.

See these feature requests:
https://www.portfolio123.com/feature_request.jsp?view=my&cat=-1&featureReqID=1325

https://www.portfolio123.com/feature_request.jsp?view=my&cat=-1&featureReqID=1324

I have done this before by parsing the dates formatted as text YYYYMMDD into serial date values. This process is very ugly and still can only approximate today’s date.

I warned you…

For example, to get PeriodDateA into serial format, where “1” represents 1 Jan 1900:

setVar(@LatestPeriodDate_Serial, trunc((trunc(PeriodDateA/10000)-1900)*365 + trunc((PeriodDateA - trunc(PeriodDateA/10000)*10000)/100)*30.42 + mod((PeriodDateA - trunc(PeriodDateA/10000)*10000),100)) )

ouch… date math functions desperately needed

what are you using to get the string for today’s date?

I take the serial serial date of the latest quarterly report and then add WeeksIntoQ*7.

Also ugly. And it is an approximation with a very wide margin of error. In fact, I was reluctant to share because I think there may be something funky with how often the dates are updated.

I’ve checked my approximation; the margin error due to rounding is about .25 days per year – this is explained by leap years – rounding error does not explain the discrepancies.

This comment is more for the P123 staff: as a general rule, generic functions are more powerful AND robust than specific calls on data that must be routinely refreshed.

Thanks for sharing your hard work. I took a look at it last night and I am also seeing some very weird results. The WeeksIntoQ variable doesn’t seem to get updated consistently and the current date estimates vary wildly between stocks.

I was able to create a Weeks to Fiscal Year variable (WeekstoFY) from the WeeksToY variable and the AnnounceDaysQ variable. It doesn’t work great, but gives decent results

$WeeksToFY = Eval((WeeksToY - (($MaxAnnounceDays_TTM/365)*52))<0,52 + (WeeksToY - (($MaxAnnounceDays_TTM/365)*52)),(WeeksToY - (($MaxAnnounceDays_TTM/365)*52)))

where

$MaxAnnounceDays_TTM = MAX of AnnounceDaysQ over the Trailing Twelve Months

there are some problems caused by weirdness in the historical values of AnnounceDaysQ which seem to bounce around a bit.