ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Excel date format trouble (https://www.excelbanter.com/excel-discussion-misc-queries/84371-excel-date-format-trouble.html)

michaelberrier

Excel date format trouble
 
I am using a magnetic stripe reader to enter a DL expiration date into
a cell. The date on the stripe is formatted as YYMM, so April of 2006
would look like 0604. The trouble comes when I want to compare that
date to today's to automatically detect an expired document.

Excel will allow a date in that format as long as it is entered that
way to start with. Otherwise, Excel will interpret the number 0604 as
six hundred four days after Jan 1, 1900.

If the cell is fomatted to show the date as YYMM, then the number 0604
returns a date of 0108, or August of 1901.

Is there any way to make Excel see an entered string of numbers as a
previously formatted date?

Thanks for any help


Peo Sjoblom

Excel date format trouble
 
But to do that you need to have a day in April to compare with today's date?

If we assume that day is the 1st

=TODAY()--TEXT(REPT("0",4-LEN(A1))&A1&"01","\2\000-00-00")


--

Regards,

Peo Sjoblom

http://nwexcelsolutions.com






"michaelberrier" wrote in message
oups.com...
I am using a magnetic stripe reader to enter a DL expiration date into
a cell. The date on the stripe is formatted as YYMM, so April of 2006
would look like 0604. The trouble comes when I want to compare that
date to today's to automatically detect an expired document.

Excel will allow a date in that format as long as it is entered that
way to start with. Otherwise, Excel will interpret the number 0604 as
six hundred four days after Jan 1, 1900.

If the cell is fomatted to show the date as YYMM, then the number 0604
returns a date of 0108, or August of 1901.

Is there any way to make Excel see an entered string of numbers as a
previously formatted date?

Thanks for any help




michaelberrier

Excel date format trouble
 
That looks like it works. Do you mind telling me how?

thanks
mb



All times are GMT +1. The time now is 09:25 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com