简体   繁体   中英

Excel Date month day year conversion

I have dates in the format:

Monday, March 25 2019

Wednesday, September 25 2019

I would like to convert them to DD/MM/YY format (ie 25/03/2019)

I have tried the following excel formula:

DATEVALUE(MID(B2,FIND(", ",B2)+6,2)&"-"&MID(B2,FIND(", ",B2)+2,3)&"-"&RIGHT(B2,4))

does anyone know where I have made an error in this formula or an alternative?

The way you find your day is incorrect, you search for ", " which is the only unique character in string, but then add 6 to that to get your date value (25) this won't work because the month names can be longer. This formula will work:

=DATEVALUE(LEFT(RIGHT(B2,7),2)&"-"&MID(B2,FIND(", ",B2)+2,3)&"-"&RIGHT(B2,4))

It takes the last 7 characters from the string (day and year, always same size assuming a leading zero in the date) and gets the first two numbers from it, matching your day.

EDIT Tested without a leading zero in the date, this seems to work as well.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM