Skip to main content
Solved

Producing dates

  • February 4, 2020
  • 1 reply
  • 15 views

Hi there,

I am trying to calculate the four date fields related to the start and end of the current and previous regulatory year based on the current date. The regulatory year starts from 1st of April and ends on 31 March of next year. So in this way current regulatory year starts from 1st April 2019 and ends on 31 March 2020. Here is my logic :

Current_regulatory_year_start: @DateTimeFormat(@DateTimeFormat(@DateTimeAdd(@DateTimeNow(),-P9M),%Y%m)01,%Y%m%d)

Current_regulatory_year_end: @DateTimeFormat(@DateTimeFormat(@DateTimeAdd(@DateTimeNow(),P2M),%Y%m)31,%Y%m%d)

Previous-regulatory_year_start: @DateTimeFormat(@DateTimeFormat(@DateTimeAdd(@DateTimeNow(),-P21M),%Y%m)01,%Y%m%d)

Previous_regulatory_year_end: @DateTimeFormat(@DateTimeFormat(@DateTimeAdd(@DateTimeNow(),-P10M),%Y%m)31,%Y%m%d)

 

However, it does not produce the desired result. Current_reulatory_year_end and previous_regulatory_year_end produce null value, whereas the other two do not produce the right date. Could you please guide me where am I making the mistake?

 

Best answer by ebygomm

To get the current regulatory year you need to take away 3 months not 9

So current regulatory year start date would be

@DateTimeFormat(@DateTimeAdd(@DateTimeNow(),-P3M),%Y)0401

From there you can calculate all the other dates

0684Q00000ArKgPQAV.png

This post is closed to further activity.
It may be an old question, an answered question, an implemented idea, or a notification-only post.
Please check post dates before relying on any information in a question or answer.
For follow-up or related questions, please post a new question or idea.
If there is a genuine update to be made, please contact us and request that the post is reopened.

1 reply

ebygomm
Influencer
Forum|alt.badge.img+44
  • Influencer
  • 3427 replies
  • Best Answer
  • February 4, 2020

To get the current regulatory year you need to take away 3 months not 9

So current regulatory year start date would be

@DateTimeFormat(@DateTimeAdd(@DateTimeNow(),-P3M),%Y)0401

From there you can calculate all the other dates

0684Q00000ArKgPQAV.png