selrac
September 3, 2019, 3:37pm
1
I need to round the current time (now()) to the earliest hour
In Excel I use the following:
FLOOR(H4,1/24)
In UiPath, if I tried:
math.Floor(now.ToOADate,1/24).ToString
But it doesn’t work as it doesn’t accept the “1/24” significance parameter
Any ideas on how to do it in UiPath?
selrac
September 3, 2019, 4:30pm
2
Playing around with the functions I managed to resolve it. Here it is in case it helps someone:
cdate(date.FromOADate((math.Floor(now.ToOADate *24))/24)).ToString
Dave
(David Wiebelhaus)
September 3, 2019, 4:32pm
3
A couple ways you can do this. The most straightforward way would be to convert it to a string, then use datetime.parseexact to convert your newly created string back into datetime. So it would be
(type = string) Assign NowAsString = now.tostring(“dd/mm/yyyy HH”)
(type = datetime) Assign YourRoundedDate = Datetime.ParseExact(NowAsString,“dd/mm/yyyy HH”,CultureInfo.InvariantCulture)
1 Like
system
(system)
Closed
September 6, 2019, 4:32pm
4
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.