How to get time ranges in a variable?

Hi, I want to get a timeRange variable

For e.g. current time is =>> 17/12/21 3:27 AM IST)
I want to cover previous 4 time ranges (11-12,12-1,1-2,2-3)
And I want my time Range variable to have below value

timeRange = 17/12/2021 11 PM to 3 AM IST

Similarly, currentTime → 17/12/21 11:15 PM IST

previous 4 timeranges → (7-8,8-9,9-10,10-11)

timeRange = 17/12/2021 7 PM to 11 PM IST

Hope it clears

If anybody can help??


Try like below. i hope it will helpful for your requirement. Thanks.

Use assign activity all are string variables

CurrentTImeVal = now.ToString(“hh”)+" "+now.ToString(“tt”)

FourHoursBeforeTimeVal = Now.AddHours(-4).ToString(“hh”)+" "+Now.AddHours(-1).ToString(“tt”)

ExpectedVal = Now.ToString(“dd/MM/yyyy”)+" “+FourHoursBeforeTime+” “+“to”+” "+CurrentTIme

maybe your request was misinterpretated when understanding as you are looking for a datatype / structure reflecting a date with time and an addtional timespan.

Maybe a tuple will help on this:

Accessing the date: yourTupleVar.Item1 | DataType: DateTime
Accessing the timespan: yourTupleVar.Item1
Calculating the end

So remaining task is to calculate the timespan from

if the suggested approach will be of interest we can help on this as also. The first case looks to me as
but we would suggest to shift to the 1,2,3,4…12,13,14…23,0 hour enumeration if this would be possible

Hi, Could u plz share the .xaml? That would be really helpful?

Will it work for all possible scenarios…cz right now it’s working. Thanks btw.

Thank you so much :slight_smile:

1 Like

i have tested different hours it was working. please do some more testing before using in real time. thanks.

Your most welcome.

Hi, It’s giving wrong value if I am taking time in PST for e.g. 2;30 AM PST
Sequence1.xaml (6.1 KB)
Please help

Result is

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.