I am looking for some help in date calculations.
I have one start date i.e. 01/04/2022. There is one more input field i.e. number of years.
For example, if I select 2 years, then following should be output considering start date is 01/04/2022.
First Year: 01/04/2021 to 31/03/2022
Second Year: 01/04/2020 to 31/03/2021
If I select 3 years, then result should be
First Year: 01/04/2021 to 31/03/2022
Second Year: 01/04/2020 to 31/03/2021
Third Year: 01/04/2019 to 31/03/2020
Please note that I need these dates showing in bold.
I somehow understand that I need to use Repeat function but not sure how to do this.
I am not sure of a way to get "First", "Second", "Third", etc. directly. Seems like that might be an interesting feature addition - to convert a number (1, 2, 3) into its position (first, second, third)
For now, I have just hardcoded these names.
Tenure of Previous Appointment: {formtext: name=pyear; default=5}
{repeat: for i in seq(1, {=pyear})}
{=i} Year: {time:DD/MM/YYYY; at={=startdate}; pattern=DD/MM/YYYY; shift=-{=i}Y} to {time: DD/MM/YYYY; at={=enddate}; pattern=DD/MM/YYYY; shift=-{=i}Y}{endrepeat}
Are you seeing any possibility of improving this snippet in any way?
That position "First", "Second" etc is not necessary for the snippet actually. But that will be helpful in future.
In addition to this, in Tenure of Previous Appointment, if it is 0 or blank, then it shows this
I want not to show anything if previous appointment is blank. Any idea?
I guess I will go with your formula. The extra point I added was "enddate" which was not necessary. I simply had to use this one.
{time: {=pattern}; shift={=-offset+1}Y-1D; at={=start_date}; pattern={=pattern}}