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")}
date to string conversion
-
- Posts: 52
- Joined: Wed May 17, 2017 10:14 pm
-
- Posts: 6254
- Joined: Tue Mar 20, 2018 5:34 am
Re: date to string conversion
Hello,
Your expression is incorrect: month - 13 and day - 0.
Please use
{(DateSerial(Year(Today), Month(Today), 1)).ToString("MM.dd.yyyy")}
Thank you.
Your expression is incorrect: month - 13 and day - 0.
Please use
{(DateSerial(Year(Today), Month(Today), 1)).ToString("MM.dd.yyyy")}
Thank you.
-
- Posts: 52
- Joined: Wed May 17, 2017 10:14 pm
Re: date to string conversion
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")}
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")}
-
- Posts: 6254
- Joined: Tue Mar 20, 2018 5:34 am
Re: date to string conversion
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.
Please try to use:
{DateSerial(Year(Today), Today.AddMonths(-2).Month, DaysInMonth(Year(Today),Today.AddMonths(-2).Month)).ToString("MM.dd.yyyy")}
Thank you.
-
- Posts: 52
- Joined: Wed May 17, 2017 10:14 pm
Re: date to string conversion
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")
DateSerial(Year(Today).AddMonths(-2), Today.AddMonths(-2).Month, DaysInMonth(Year(Today),Today.AddMonths(-2).Month)).ToString("MM/dd/yyyy")
-
- Posts: 6254
- Joined: Tue Mar 20, 2018 5:34 am
Re: date to string conversion
Hello,
Thank you for the information.
Thank you for the information.