Im having Service now ticketing tool in that ticket opened time will be there. I used get text activity to get time. but unable to get previous hour of that time. Please help me
Hi @swapna
Are you searching for the same as shown below :-
If yes then below is the workflow for the same :-
MainPratik.xaml (6.9 KB)
Below statement will give you the Time one hr before from the current time :-
DateTime.Now.AddHours(-1)
Mark as solution and like it if this helps you
Happy Automation
Best Regards
Er Pratik Wavhal
Not sure if I understand what you are trying to do but yeah to get the previous hour you can use the AddHour()
function see this example would give you the previous hour but current time in terms of minutes and seconds Now.AddHours(-1).ToString("H:mm:ss")
the below can be a great reference guide when working with DateTime:
Yes, this is what i need but here my problem is. when i use “Get text activity” to get time from ServiceNow portal and variable will be of String format i’m unable to change it to DateTime. If i use String then i couldnt use AddHour function
Ideally, I use variable of String how could i convert it to DateTime
Hi @swapna
You can do it by 2 ways as below :-
1st Way :-
DateTime variable = CDate(strVariableThatYouGetFromGetTextActivity).AddHour(-1)
2nd Way :-
DateTime variable = DateTime.ParseExact(CDate(strVariableThatYouGetFromGetTextActivity).ToString("dd-MM-yyyy"),"dd-MM-yyyy",System.Globalization.CultureInfo.InvariantCulture).AddHour(-1)
Note :- In place of “dd-MM-yyyy” for 2nd Way you have to provide the DateTime Format in which you get the Date String from Get Text Activity
Mark as solution and like it if this helps you
Happy Automation
Best Regards
Er Pratik Wavhal
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.