How to convert the time interval with respect to dates

Hi Team,

Please help with , I am receiving the time interval in strings as 19:00:00-04:00:00. How to convert it to start time :- 08/01/2020 19:00 and end time 08/02/2020 04:00 ?

Thanks.

1 Like

Hi,

Hope the following steps helps you.

Let’s say strData = "19:00:00-04:00:00"

Then

timeStrArray = strData.Split({"-"c,":"c})
timeFrom = new DateTime(2020,8,1,CInt(timeStrArray(0)),CInt(timeStrArray(1)),CInt(timeStrArray(2)))
timeTo = new DateTime(2020,8,2,CInt(timeStrArray(3)),CInt(timeStrArray(4)),CInt(timeStrArray(5)))

timeFrom and time To are DateTime type variable.

Regards,

1 Like

well i have the input date as 08/01/2020 only, so need to calculate the 08/02/2020, while converting.

Hi,

How about the following?

If ToTime is eariler than FromTime, Add 1 day to ToTime.

Regards,

Does the interval can be greater than 24h?
If no, @Yoichi 's answer is what you need.
If yes, it’s not possible to create the a logic just with the first date.

Thanks Yoichi!

1 Like

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