Hi All,
I need to add 2 hours to the time below and incase if the time is 22:00 or more to add one more day to the date.
01.07.2019 17:44
The above is a string variable.
Any one know how to do this? Many thanks
Hi All,
I need to add 2 hours to the time below and incase if the time is 22:00 or more to add one more day to the date.
01.07.2019 17:44
The above is a string variable.
Any one know how to do this? Many thanks
Fine if the input is
Str_date = β01.07.2019 17:44β
Then
str_date_output = If(Convert.ToInt32(Split(Str_date,β β)(1).ToString.SubString(0,2))>=22, DateTime.ParseExact(Str_date,βdd.MM.yyyy HH:mmβ,System.Globalization.CultureInfo.InvariantCulture).AddHours(2).ToString(βdd.MM.yyyy HH:mmβ),str_date)
Cheers @tra_my_Tran
Hi,
Convert your string value to datetime value first:
datetimevar = DateTime.ParseExact(β01.07.2019 17:44β,βdd.MM.yyyy hh.mmβ,CultureInfo.InvariantCulture)
Next use methods of datetime class to achieve the desired.
See DateTime Struct (System) | Microsoft Learn for more
Cheers
Hi @Palaniyappan,
I tried but it s not working, can you give me a demo?
Thank you so much
Fine
here you go with a xaml
hope its resolved
time.zip (9.5 KB)
Cheers @tra_my_Tran
Hi @Palaniyappan,
Thanks for your support, just tried your demo
however i wanted is like:
if the text is β11.09.2017 13:20β then i want result is β11.09.2017 15:20β
If the text is β11.09.2017 23:00β then i want the result is β12.09.2017 1:00β
Is it possible to fix like that?
Thank you so much
hi @tra_my_Tran,
lets take,
strdate1 = β11.09.2017 23:00β
Then, take 1 assign
date1(DateTime) = DateTime.ParseExact(strdate1,βdd.MM.yyyy HH:mmβ,System.Globalization.CultureInfo.InvariantCulture).AddHours(2)
writeline β> date1.ToString(βdd.MM.yyyy HH:mmβ)
Donβt worry about the date, itβll change automatically, because here weβre converting that string into DateTime format and adds 2 hours in that date using datetime method called AddHours, So after adding 2 hours date will automatically change.
Hi @samir,
Thanks a lot, it s working for me ^^
Hi @tra_my_Tran,
Try the below code
Create varaible dateVar as datetime
Assign following code using assign activity
dateVar = DateTime.ParseExact(β11.09.2017 13:20β, βdd.MM.yyyy HH:mmβ,null);
dateVar.AddHours(2).ToString()
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.