Hi Team,
I Need to extract the previous month 1st date new so i use this DateTime(Now.Year,Now.Month,1).AddMonths(-1) but in this i am getting “01” but I need “1” I use temp_month.tostring("M")
but am getting like this April 01
can anyone help me how to get “1” no zero
Hi @copy_writes
Can you convert the final result to string then use a string.replace?
YourString.Replace(“01”, “1”)
Hopefully this helps.
Cheers
Steve
1 Like
do this
datepart("m", new DateTime(Now.Year,Now.Month,1).AddMonths(-1))
add .toString at the end if you want it to be string
1 Like
if the next run is 02 or 05 what we have to do i hope it will fail there
Yoichi
(Yoichi)
May 11, 2022, 6:37am
7
Hi,
Can you try either of the following?
tempMonth.ToString("%M")
or
tempMonth.Month.ToString()
Regards,
2 Likes
Hi again
You could use Regex to remove the leading 0.
Left Assign:
YourStringResult
Right Assign:
System.Text.RegularExpressions.Regex.Replace(INSERTVARIABLE, “(?<=January |February |March |April |May |June |July |August |September |October |November |December )0(?=\d)”, “”)
Take a look here .
Hopefully this helps.
Cheers
Steve
1 Like
This code also works thanks @Yoichi
Hi guys, with stuff like this I recommend using the power of low code to find a statement as simple as possible.
How about this?
new Date(Today.Year,Today.Month,1).AddMonths(-1).ToString("MMMM d")
Cheers,
Lukas
system
(system)
Closed
May 14, 2022, 6:46am
11
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.