Hi, I have attached a robot to this post. I don’t know what the extensions to the assign do (TryParse, ParseExact, etc). I also don’t know why there is a message box to show the time when time was not assigned to strDate variable. I tried to google but don’t really understand.
Date_arithmetic (1).xaml (10.4 KB)
tryParse - checks if string is a valid datetime, in this case the string to check is strDate(20-06-2022), it returns true if success , false if failed hence why it was used in the if statement
the messagebox is showing
datetime_for_demo.ToLongDateString not strDate
and before the messagebox, you assigned
datetime_for_demo = DateTime.ParseExact(strDate, "dd MMM yyyy", System.Globalization.CultureInfo.InvariantCulture)
parseExact means you try to parse strDate into a date using the specified format (in this case “dd MM yyyy”)
Here is quick guide to get familiar with DateTime Conversions,
C# convert string to datetime. Learn how to convert a string to datetime in C#. There are several common methods including Convert.ToDateTime, DateTime.Parse, and DateTime.ParseExact to convert a string into a DateTime in C#.
HAPPY AUTOMATION !!!