Date format tricky

I have the dates in the format: 10/16/2019
and I need only 10/2019 form it . Could any one help me in this.

1 Like

Hi @kartik_sareen,

Please try with the below -
DateTime.Now.ToString(“MM/yyyy”)

Hope you find your solution.

Thanks & Regards,
Apurba

3 Likes

Thanks a lot, sometimes small thigns doesnt come up…

1 Like

Yea @kartik_sareen, it happens.

Thanks & Regards,
Apurba

Thanks buddy, now I need the date in the format
dd/mm/yyyy and it should always be 31st or 30th of the previous month so if the BOT is running today then it should be 30/09/2019

Hi @kartik_sareen,

But September doesn’t have 31st day. So what to do?

Thanks & Regards,
Apurba

ohh sorry , just an example…so for september it would be 30

ohh sorry , just an example…so for september it would be 30

Pass this to a DateTime Variable, you will get previous monthend date in that.

New DateTime(Now.Year, Now.AddMonths(-1).Month, DateTime.DaysInMonth(Now.Year, Now.Month-1))

1 Like

Hi @kartik_sareen,

I’m attaching a workflow for your convenience. Hope it will help you.
Main.xaml (11.9 KB)

Thanks & Regards,
Apurba

Hi, Well Date.Now(-1).ToString(“MM/yyyy”), will it work to give the date for the previous day

Hi @kartik_sareen,

I don’t think that Date.Now(-1).ToString(“MM/yyyy”) will work to find the previous day.

To get previous date please try with the below -
now.AddDays(-1).ToString(“dd/MM/yyyy”)

Thanks & Regards,
Apurba

1 Like

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