Date conversion with days of the week

Hi team,

i have date formates as below
Date1= Sun Sep 08 00:00:00 IST 2022
output should be - 09/08/2022

Date2= August 4,2022
Output should be - 08/04/2022

please help here

@Tuhdae @kuppu_samy @Spark_robot please help here

@dlmsekhar
Ok wait…

1 Like

Hello @dlmsekhar,

For the second one you can use

Convert.ToDateTime("August 4,2022").ToString("dd/MM/yyyy")

But for the first option am not sure if we ca do it in .net, however in google sheet it’s can be done easily using the formula

=ArrayFormula(TEXT(DATEVALUE(TEXTJOIN("-",TRUE,TRIM(MID(SUBSTITUTE(A1," ",REPT(" ",100)),{2,1,5}*100,100)))),"dd/MM/yyyy"))

Thanks,
Sanjit

1 Like

i got it for second one :
Datetime.ParseExact(a,“MMMM d, yyyy”,System.Globalization.CultureInfo.InvariantCulture).ToString(“MM/dd/yyyy”)

1 Like

@dlmsekhar
For First and second
System.Datetime.ParseExact(Date1,“MM/dd/yyyy HH:mm:ss”,New system.Globalization.CultureInfo(“en-US”)).ToString(“MM/dd/yyyy”)

Replace to remove the IST and Remove to get rid of the first 4 characters:

“Sun Sep 08 00:00:00 IST 2022”.Replace(“IST “,””).Remove(0,4)

Use this in your ParseExact:

Datetime.ParseExact(“Sun Sep 08 00:00:00 IST 2022”.Replace(“IST “,””).Remove(0,4),“MMM dd hh:mm:ss yyyy”,System.Globalization.CultureInfo.InvariantCulture).ToString

Result of the replace/remove, then the parse:

image

1 Like

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