Hi the automation Team,
I am facing one issue to round off the time.
When I am running the bot, I have to look into 1 hour back for an example if I am running the bot at 14:25 I have to look the data 1 hour before so my bot should pick the data for 13:25. But I need to extract the data at 13:00, means I need to round the time to the fixed date instead of minutes.
Kindly help me on this
Thanks
ppr
(Peter Preuss)
October 23, 2023, 9:19am
2
Some parts are unclear form the description. Maybe you are looking for this:
Enhanced to the following, getting it work on day borders
AJ_Ask
October 23, 2023, 9:26am
3
You can round the time to the nearest fixed hour using the following code:
currentTime = currentTime.Date.AddHours(currentTime.Hour)
Finally, you can subtract one hour to get the time you want. using Following Code:
currentTime = currentTime.AddHours(-1)
Thanks For Quick Reply
I am using the below format
Now.ToString(“dd MMM yyyy”)+" "+DateTime.Now.AddHours(-1).ToString(“hh:mm tt”)
This will give me the format as 23 Oct 2023 02:09 PM so I need to round off this to 23 Oct 2023 02:00 PM
Thanks
ppr
(Peter Preuss)
October 23, 2023, 9:44am
5
when it is always about base lining it to 00
DateTime.Now.AddHours(-1).ToString("hh:00 tt")
But keep in mind:
when a 00:25 is also to handle it will be the day before for a right date calculation
Also have a look at this:
Assign Activity:
myDate = Now()
Assign Activity
myBaseDate = myDate.addHours(-1).AddMinutes(-myDate.Minute)
1 Like
system
(system)
Closed
October 26, 2023, 9:44am
6
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.