How to assign a current date - 1 day and time set to 00:00:00 on the website date-time field

studio

#1

Hi everyone,

how to assign a current date - 1 day and time set to 00:00:00 on the website’s “date-time” field
e.g.From Date: 17/06/2018 00:00:00, using UIPath to set it to 16/06/2018 00:00:00.

Please advise


#2

You can assign the current date by the formula :

String.Format("{0:dd/MM/yyyy}", DateTime.Now)

To add or subtract days you can use :

DateTime.Now.AddDays(-1)
or
String.Format("{0:dd/MM/yyyy}", DateTime.Now.AddDays(-1))

P.S: Please like and mark as Solution if this solves your issue :slight_smile:


#3

how to i do i set the timing to 00:00:00?


#4

To set the time to 00.00.00 use,

DateTime.Now.AddDays(-1).AddHours(-DateTime.Now.Hour).AddMinutes(-DateTime.Now.Minute).AddSeconds(-DateTime.Now.Second)

For 24 hours format,

String.Format("{0:dd/MM/yyyy HH:mm:ss}", DateTime.Now.AddDays(-1).AddHours(-DateTime.Now.Hour).AddMinutes(-DateTime.Now.Minute).AddSeconds(-DateTime.Now.Second))


#5

@Eros check attached file

PreviousDayAndTime.xaml (6.0 KB)


#6

Nice


#7

Thanks for all the help.