简体   繁体   中英

Date format conversion in Excel

I have a list of dates, which seem to be in dd/mm/yyyy hh:mm format ( Ex - 12/13/2022 12:16 AM ) , which is incorrect. I need to change to mm/dd/yyyy hh:mm format.

I tried the formula =IF(H2="","",IF(DAY(H2)>12,DAY(H2)&"/"&MONTH(H2)&"/"&YEAR(H2),VALUE(DATE(YEAR(H2),DAY(H2),MONTH(H2)))))

but the result is #Value

例子

在此处输入图像描述

You seem to be missing the point: a datetime format in Excel is a normal number, where 1 means one day, starting at the first of January, 1900.

Let me show how it looks on my PC:

在此处输入图像描述

As you can see, there are two ways to describe the thirteenth of December, 2022:

  • format dd/mm/yyyy : 13/12/2022 (European style)
  • format mm/dd/yyyy : 12/13/2022 (American style)

But as you can see below, the actual values are the same ( 44908 is the amount of days starting at January first 1900).

Doing calculations on this, like checking =DAYS()>12 , has no meaning, because the days will be calculated from that 44908 number, not from the way it's displayed.

So, don't start formulas on that, just alter the way it's displayed (using cell formatting, as shown in my screenshot).

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