How to check if string can be checked with DateTime.TryParse in Assing activity

My scenario is im reading value from in_Config(“LastRun”)

I want to check if the value is

Dt_LastRun = 
If(( Not String.IsNullOrWhiteSpace(in_Config("LastRun").ToString)) And DateTime.TryParse(in_Config("LastRun").ToString)) {DateTime.Parse(in_Config("LastRun").ToString)} '
Else {DateTime.Now.ToString("ddMMyyyy")}

i want to write that code in assing value and assing either DateTime.Parse(in_Config("LastRun").ToString) or DateTime.Now.ToString("ddMMyyyy") based on condition

but the code is wrong offcource becuase its combination of C# and Vb.Net and i dont know how to write that logic in Assign Activitiy

@sagar.raval

You can try this

If(DateTime.TryParse(in_Config("LastRun").ToString, Nothing),Cdate(in_Config("LastRun").ToString).ToString("ddMMyyyy"),Now.ToString("ddMMyyyy"))

cheers

Hi

Hope this would help you

Dt_LastRun =
If( Not String.IsNullOrWhiteSpace(in_Config(“LastRun”).ToString.Trim)
And DateTime.TryParseExact(in_Config(“LastRun”).ToString.SubString(0,10), “dd/MM/yyyy”, Nothing,Globalization.DateTimeStyles.None,Nothing), DateTime.ParseExact(in_Config(“LastRun”).ToString.SubString(0,10), “dd/MM/yyyy”, System.Globalization.CultureInfo.InvariantCulture).ToString(“ddMMyyyy”), DateTime.Now.ToString(“ddMMyyyy”)
}

To know more about datetime

Cheers @sagar.raval

Hi,

Try this

Dt_LastRun = If(Not String.IsNullOrWhiteSpace(in_Config(“LastRun”).ToString), If(DateTime.TryParse(in_Config(“LastRun”).ToString, Dt_LastRun), Dt_LastRun), DateTime.Now.ToString(“ddMMyyyy”))

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.