简体   繁体   中英

Excel: Date formatting 'YYYY-MM-DD' after being selected not showing correctly in concatenation

I've copied data into Excel from a SQL database. The way the data is formatted before it gets copied over is: YYYY-MM-DD

After it gets copied over, it shows in excel as M/DD/YYYY .

I right-clicked the column and selected Format Cells to a custom format just as I needed.

The problem is that if I select the value, although the spreadsheet shows the value I need, the actual value itself is different (I'll include a screenshot to show what I'm seeing):

选择时Excel显示不同的日期格式

My end goal is to select an empty cell and do a simple formula which is:

=" DateValue="&B1&" "

But it outputs something completely different. Example: If my date was 2016-09-23 or just as it shows above in the image, when applying the formula above, I get:

DateValue=42636

When what I need is :

DateValue=2016-09-23

Can anyone advise how to achieve this end goal?

Use:

=" DateValue="&TEXT(B1,"yyyy-mm-dd")&" "

在此处输入图片说明

It does not matter what the format of B1 is. You force the desired format in the C1 formula.

You can nest TEXT function within CONCAT function. Text function returns the text in the desired format, and concat function concatenates strings. Following formula will convert the date in cell A1 to the desired output:
=CONCAT("DateValue=", TEXT(A1, "yyyy-mm-dd"))

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