Support > Forums > OpenBots Studio > Date comparison
Good day. How can I get the difference in days from 2 dates I can get with the command Format Date, since the output are string type variables.
This forum has 317 topics, 687 replies, and was last updated 4 months ago by Nataly Alvarado...
Hi alfredo.carbajal.nips,
To perform this calculation you can utilize a C# code snippet by using the Set Variable or Evaluate Snippet command. To find the difference in days (output double variable), use the below format:
(EndDate - StartDate).TotalDays Make sure EndDate and StartDate are DateTime variables. If they are not, then you can convert your string to DateTime before the subtraction: DateTime.Parse(DateString) A complete code snippet would look like: (DateTime.Parse(EndDateString) - DateTime.Parse(StartDateString)).TotalDays.ToString() Hope this helps!
You are not authorized to reply, please click here to login and add your reply to this topic.