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 314 topics, 681 replies, and was last updated 20 days ago by Support Agent
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.