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

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

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:

2 Likes

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

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))

3 Likes

@Eros check attached file

PreviousDayAndTime.xaml (6.0 KB)

Nice

1 Like

Thanks for all the help.

1 Like

Alternate:
To set the time to 00.00.00 use,
now.Date.AddDays(-1)

it will gives you date+timestamp 00.00.00
ex. 02/04/2019 00:00:00
o/p: 02/03/2019 00:00:00

1 Like