How to use DateTime.TryParse()

Hi guys,

I’m using DateTime.TryParse(in_Date, CalendarDate) to check whether the value and the format of in_Date is correct.

The above Data type are:

If I understand correctly, It supposed to pass the converted data from in_Date to CalendarDate if the return result if true

The return result I got is true, but it didn’t pass the Converted Date to CalendarDate

The given value of in_Date is 4/5/2020,
but the return result of CalendarDate is 1 for Year, Month and Day.(00010101(yyyyMMdd))

Thanks for any advice.


If you use Assign activity, it does not support ref type argument.
So, can you try Invoke Method activity?



@opas1216, Please refer below link to get more detail around DateTime.TryParse:


@opas1216 - you can use the regular expression to validate the date…

you can use below expression to verify/validate the date string. based on match status - you can use CDate(in_Date.ToString) to convert to a date.


1 Like

Hi @Yoichi
Yes, I did use the Assign Activity, I thought it support ref type.
Is that means, normally it should support ref type, but however it didn’t?

Thanks for you help, I’ll try it later.


Thanks for you reply.

I also tried using regex like you said.

I 'll try your way later, but it need some time to let me understand your method. :sweat_smile:
your expression is more complex than mine.

I just used like “[0-9{1,2}/[0-9{1,2}/[0-9{4}]” to match for example like 2020/04/08…etc.
Could you explain more detail what targets are your regular expression matching?

Thanks you again for your help and sharing. :slight_smile:

@opas1216 - Its a combination of date formats along with leap year check as well.
You can try and let us know if you need further help…