Detect different type of date

Date.ParseExact(str_date, “MM/dd/yyyy HH:mm:ss”, System.Globalization.CultureInfo.InvariantCulture).Day

Good afternoon, this is my code to detect a certain type of date such as “02/04/2020 15:24:49”

I want you to also be able to detect different types like these for example:

02.04.2020 15:24:49
04-02-2020 15:24:49

Note: this in format is month day year

1 Like

@bcorrea

@borismh

May I know what you want to do after detecting different type of date ?

1 Like

@lakshman
I want to get the day

I also want to change the order to yyMMdd and add it two days before or after

@borismh

Use CDate function and it will convert any type of date to required date format.

    CDate("yourStrDate").AddDays(-2).Tostring("yyMMdd")

If you want next 2 days replace -2 with 2.

1 Like

@lakshman

I will try it and see if it works thanks

1 Like

I get that is not valid

@borismh

Could you please show me screenshot of it and need to check once how you specified expression.