How to get date 1sy day of month

Hi all
how to get date 1st day of month?

1 Like

Hey there, in order to help you can you provide an example?
Your question is vague

2 Likes

Actually now.AddDays(-1).ToString(“dd.MM.yyyy”) this formula is get yesterday’s date
but I want 1st day of months date
what function should I use?
Thanks

1 Like

hello @Abubakkar
please use “date.Now.AddDays(-(date.Now.Day-1)).DayOfWeek.ToString” to get the first day of the month.

Regards,
Ajay

3 Likes

@Abubakkar

Below one will give you first day of Month.

DateTime dt = new DateTime(DateTime.Now.Year, DateTime.Now.Month, 1)

8 Likes

its working @Ajju but I want numeric date is it possible?
For ex: 01.05.2019

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

8 Likes

It’s working fine Thanks@buddy

1 Like

How to get starting month of this year(2020)

You can use the first day of the current month:

New DateTime(Now.Year,Now.AddMonths(0).Month,1).ToString(“dd.MM.yyyy”)

Please assing a string variable :slight_smile:

You can use modify date activity.

Thanks

To get the first date of any month use
Var
FirstDayOfAMonth=new system.datetime(now.year,now.month,1).ToString(“dd/MM/yyyy”)

2 Likes

Hi Lakshman,

How can I get first working day of next month ? It should not be Saturday or Sunday.
Any help will be appreciated.

Thank You

Hi @Chetan_Wagh

Welcome to the UiPath Community

Please refer the below Xaml file for the logic
DateTime.xaml (6.6 KB)

ASsign - New DateTime(Now.Year,Now.Addmonths(1).Month,1) gives you the 1st date of next month
Variable.DayOfWeek.ToString = “Sunday” Or Variable.DayOfWeek.ToString = “Saturday” will check wheather if it is sunday or saturday
Variable.AddDays(1) will add 1 day if it is sunday or saturday

so this will give exact working day.

Regards,
Vasanth Kumar

1 Like

Thank you so much @V_Vasanth_Kumar :smiling_face:

1 Like

hi i encounter below. do anyone know why?
image

but mine is >
date.Now.AddDays(-(date.Now.Day-1)).Date.ToString(“MM/dd/yyyy”)

Hi @winnie_toh

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

Make sure to remove the double quotes and give it again. This error is because of that.

For more information about DateTime please refer the below thread.

Hope it helps!!

hi thank you for responding!
but when i remove the double quote there is error?
image

anyway i tried with below instead, seems ok for now but i haven got chance to test due to calendar element does not allow type in due to disabled. :frowning:
now.month.ToString+“/1/”+now.Year.ToString

@winnie_toh
Give the double quotes where you had before again. It will solve the error.
Paste this syntax:

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

Regards,

i encountered
image