Hi all
how to get date 1st day of month?
Hey there, in order to help you can you provide an example?
Your question is vague
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
hello @Abubakkar
please use “date.Now.AddDays(-(date.Now.Day-1)).DayOfWeek.ToString” to get the first day of the month.
Regards,
Ajay
Below one will give you first day of Month.
DateTime dt = new DateTime(DateTime.Now.Year, DateTime.Now.Month, 1)
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”)
It’s working fine Thanks@buddy
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
To get the first date of any month use
Var
FirstDayOfAMonth=new system.datetime(now.year,now.month,1).ToString(“dd/MM/yyyy”)
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
Thank you so much @V_Vasanth_Kumar
hi i encounter below. do anyone know why?
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?
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.
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