Store the format of a date


Posted by Rob A on October 08, 2001 5:32 AM

I need to take a date in a certain format and store it in that same format so adding additional characters to the date doesn't revert it back to default style. e.g. I have dates in cells in the format yyyy/mm/dd. When looking at the cell it appears in that format. Excel seems to store it as dd/mm/yyyy so when i take another macro to add :"date", to it the date refers back to the dd/mm/yyyy format. So I have a date 2001/09/15 (yyyy/mm/dd) and I want to make it :"2001/09/15", but at the moment adding the formatting reverts the date to :"dd/mm/yyyy", any help would be most appreciated. Cheers

Posted by Jonathan on October 08, 2001 5:48 PM

Hmmm. Just some thoughts:

Excel stores the date as a serial number. Like today is 37172 (the number of days since Jan 0, 1900). So I don't think that's it.

You could adjust it in the Regional Settings of Control Panel, but of course that would adjust it everywhere on your system.

Would it be possible in the second macro to refer to it not as "date" but as "Format(date, "yyyy/mm/dd")" ?

Just some thoughts,

jg



Posted by Don C on October 09, 2001 5:18 AM

In an out of the way cell, key a date with the formatting you want. Then when you make a change, copy and paste the format from that cell. A macro would make this quick and almost transparent.

Not quite a "real" fix, but could get you to the desired end.