Link to home
Start Free TrialLog in
Avatar of gmollineau
gmollineauFlag for Trinidad and Tobago

asked on

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.
Avatar of als315
als315
Flag of Russian Federation image

If yor cell with date is A1, you can use:
=YEAR(A1)*10000+MONTH(A1)*100+DAY(A1)
ASKER CERTIFIED SOLUTION
Avatar of barry houdini
barry houdini
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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.
.....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
This question has been classified as abandoned and is closed as part of the Cleanup Program. See the recommendation for more details.