I am trying to convert a string (which is a date I used data scrape to capture) of Nov 21, 2019 to 21/11/2019. I then want to compare it with today’s date to see if it matches.
Does anyone know how to convert the string to date format?
Fine
this expression would help you on that
if the input is str_input = “Nov 21, 2019”
then to compare with todays date in IF condition with this expression Datetime.ParseExact(str_input,“MMM dd, yyyy”,system.Globalization.CultureInfo.InvariantCulture).Date.ToString.Equals(Now.Date.ToString)
and to get that as a datetime variable datetime_var = Datetime.ParseExact(str_input,“MMM dd, yyyy”,system.Globalization.CultureInfo.InvariantCulture)
you were almost done
yah ensure that confimationDate is a variable of type System.Date.Datetime
we can search that in Browse Type in variable panel under the column Datatype
and also in the expression you missed out one y along the year
like this
Datetime.ParseExact(str_input,“MMM dd, yyyy”,system.Globalization.CultureInfo.InvariantCulture)
Sorry for the stupid questions - but if I change the variable to System.DateTime my other Assign activities where I use the variable wont validate. For example I am assigning value from a data table to that variable and then removing some characters at the end and then trying to convert that string to a sate format - like the below screen shots
Fine
the sequence be like this
–hope you have a datatable variable ready
–then inside the FOR EACH ROW activity use a ASSIGN activity like this str_input = row(“Column1”).ToString.Substring(0,12)
where str_input is a variable of type string
–now use a ASSIGN ACTIVITY like this confirmationDate = Datetime.ParseExact(str_input,“MMM dd, yyyy”,system.Globalization.CultureInfo.InvariantCulture)
where confirmationDate is a varaible of type System.Date.Datetime
then to compare with todays date
use IF activity with condition like this Datetime.ParseExact(str_input,“MMM dd, yyyy ”,system.Globalization.CultureInfo.InvariantCulture).Date>Now.Date
if true it will go to THEN part or goes to ELSE part