Day of year - Date

Stimulsoft Reports.NET discussion
Post Reply
brjohnsmith
Posts: 30
Joined: Mon Jan 29, 2018 11:04 am

Day of year - Date

Post by brjohnsmith »

Hi, how to convert day of year to date? thx
Lech Kulikowski
Posts: 6197
Joined: Tue Mar 20, 2018 5:34 am

Re: Day of year - Date

Post by Lech Kulikowski »

Hello,

You can use the following expression:
{DateSerial(2023,1,1).AddDays(dayOfYear - 1)}

Thank you.
Attachments
Screenshot 2023-03-01 200806.png
Screenshot 2023-03-01 200806.png (20.91 KiB) Viewed 715 times
brjohnsmith
Posts: 30
Joined: Mon Jan 29, 2018 11:04 am

Re: Day of year - Date

Post by brjohnsmith »

Hi Lech Kulikowski, it worked, however, I have a new challenge.

Suppose that the year is a string (that was taken using Substring function), and has 2 digits, it means, the Substring returns 23. I am supposing that the year must be decimal and 4 digits, and as it is returning string, I need to convert it in decimal. I tried to use (decimal) before the Substring, but it didn't work, because I was concatenated 20+(decimal) Substring(xx,4,2).
A new question, will this function support leap year?
thx
Lech Kulikowski
Posts: 6197
Joined: Tue Mar 20, 2018 5:34 am

Re: Day of year - Date

Post by Lech Kulikowski »

Hello,

You can use the following expression:
{DateSerial(int.Parse(Substring(Variable1,2,2)),1,1).AddDays(dayOfYear - 1)}

Thank you.
Attachments
Screenshot 2023-03-03 164943.png
Screenshot 2023-03-03 164943.png (33.8 KiB) Viewed 689 times
Post Reply