• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 448
  • Last Modified:

Convert Excel date to the same number

I have an Excel file with one column of DATE format field. I want to convert this to a number but keep the same data. for example 20110101 should stay as 20100101 (as a NUMBER format) instead of 40179 that Excel converts it to if I do a change format.
0
gmollineau
Asked:
gmollineau
1 Solution
 
als315Commented:
If yor cell with date is A1, you can use:
=YEAR(A1)*10000+MONTH(A1)*100+DAY(A1)
0
 
barry houdiniCommented:
This should also do it....

=TEXT(A1,"yyyymmdd")+0

regards, barry
0
 
Gašper KamenšekExcel MVPCommented:
The correct way would actually be to press Ctrl+1 ( or right click and choose Format cells) go to custom format, and write yyyymmdd or yyyyddmm which ever you prefer.
With this you achieve precisely what you want. You still have the same data, but in the format you desire.
Best of  luck.
0
 
barry houdiniCommented:
.....I think that's exactly what gmollineau is trying to avoid GasperK. If you do that then the format only is changed (not the cell contents) and if you change the format to general you'll see a number like 40179.

My suggestion and the suggestion of als315 both use an extra cell to do the conversion, you can only change the cell content "in situ" if you use VBA.

regards, barry
0
 
Ingeborg Hawighorst (Microsoft MVP / EE MVE)Microsoft MVP ExcelCommented:
This question has been classified as abandoned and is closed as part of the Cleanup Program. See the recommendation for more details.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now