Date format-01

Hey Team
I need date like 01.currentmonth.currentyear to 01.currentmonth.currentyear(-1)Privious day
How I can get this?

Hi @Kuldeep_Pandey
Give a try to this
date1=New DateTime(now.year,now.month,01).ToString(“dd.MM.yyyy”)
date2=New DateTime(now.AddYears(-1).year,now.month,01).ToString(“dd.MM.yyyy”)

@Kuldeep_Pandey

Can you specify the format of the current month & thecurrent year? are they like March or 03?

Best Regards.

Hi,

Do you need last day of previous month? if so then pls use below code:

date.Now.AddDays(-(date.Now.Day-1)).Date.AddDays(-1).ToString(“dd.MM.yyyy”)

Happy Automation! :grinning:
Please do mark as a solution if it helps you. :writing_hand: :white_check_mark:

2 Likes

Sorry I want 01.current month.currentyear to like current day date(-1) like today is 10 so Output like
01.03.2023 to 09.03.2023

Hi @Kuldeep_Pandey
Check this
date1=New DateTime(now.year,now.month,01).ToString(“dd.MM.yyyy”)
date2=New DateTime(now.year,now.month,now.AddDays(-1)).ToString(“dd.MM.yyyy”)

Hi @Kuldeep_Pandey ,

If the interest is only with the String Representation and if no need to store the values as Date type, then you could check the below Expression :

Now.ToString("01.MM.yyyy")+" to "+Now.AddDays(-1).tostring("dd.MM.yyyy")
2 Likes

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.