Date Split

Hi Team,

I have a date in format say 01Jan2020. I want to split like below

01
01
2020

preferably each line stored in a separate variable.

1 Like

@Balan: You can use following statements:

someDate = DateTime.ParseExact(“01Jan2020”, “ddMMMyyyy”, CultureInfo.CurrentCulture)

Day = someDate.Day.ToString(“00”)

Month = someDate.Month.ToString(“00”)

Year = someDate.Year.ToString

Cheers :slight_smile:

3 Likes

Use substring method
Date = yourString.Substring(0,2) will return 01

Thanks
@Balan

2 Likes

Hi,

Hope the following helps you.

datetimeVar = DateTime.ParseExact("01Jan2020","ddMMMyyyy",nothing)

Then

strDay = datetimeVar.ToString("dd")

strMonth =  datetimeVar.ToString("MM")

strYear =  datetimeVar.ToString("yyyy")

Regards,

3 Likes

@ Bhavik_Solanki its working fine thanks. Thanks other guys for your support.

2 Likes