Page 1 of 1
date to string conversion
Posted: Wed Dec 28, 2022 2:37 am
by ddsmith99301
I am trying to convert a date to a string. Any help will be appreciated. Here is what I tried but didn't work.
This is the expression I used in a text box.
{(DateSerial(Year(Today), Month(Today) + 1, 0)).ToString("MM.dd.yyyy")}
Re: date to string conversion
Posted: Wed Dec 28, 2022 8:05 am
by Lech Kulikowski
Hello,
Your expression is incorrect: month - 13 and day - 0.
Please use
{(DateSerial(Year(Today), Month(Today), 1)).ToString("MM.dd.yyyy")}
Thank you.
Re: date to string conversion
Posted: Wed Dec 28, 2022 7:40 pm
by ddsmith99301
Thank you so much for replying during this holiday season. I have a project deadline of this coming Friday and I am scrambling to get it done on time.
Someone gave that as a way to find the end of the month. I guess they didn't realize that December wouldn't work.
Here is my solution for the end of the current date's month.
{(DateSerial(Year(Today), Month(Today) ,DaysInMonth(Year(Today),Month(Today)))).ToString("MM.dd.yyyy")}
And for two months earlier. Unfortunately, this only works if the Month is greater than 2.
{(DateSerial(Year(Today), Month(Today) - 2,DaysInMonth(Year(Today),Month(Today) - 2))).ToString("MM.dd.yyyy")}
Re: date to string conversion
Posted: Thu Dec 29, 2022 7:55 am
by Lech Kulikowski
Hello,
Please try to use:
{DateSerial(Year(Today), Today.AddMonths(-2).Month, DaysInMonth(Year(Today),Today.AddMonths(-2).Month)).ToString("MM.dd.yyyy")}
Thank you.
Re: date to string conversion
Posted: Mon Jan 02, 2023 9:12 pm
by ddsmith99301
I have a little correction. This is how I got it to work.
DateSerial(Year(Today).AddMonths(-2), Today.AddMonths(-2).Month, DaysInMonth(Year(Today),Today.AddMonths(-2).Month)).ToString("MM/dd/yyyy")
Re: date to string conversion
Posted: Tue Jan 03, 2023 9:30 am
by Lech Kulikowski
Hello,
Thank you for the information.