#1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 28
Default Formatting Dates

I have a column of dates. These dates are stored in the cell as "112482" and
the cell is formatted as "00\/00\/00" so that in the cell it looks like:
"11/24/82".

The problem is, I can't sort these dates because they are not stored
correctly in the cell for Excel to recognize them like it should. For
instance, "112482" is seen by Excel as 112,482nd day after January 1st, 1900
or 12/18/2007.

It appears there is no function in Excel currently to format my dates
correctly so it can be sorted by Excel. Can I create one using VBA? What
would it be?
  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 4,339
Default Formatting Dates

In a helper column format as DATE

=DATE(RIGHT(A1,2),LEFT(A1,2),MID(A1,3,2))



"MEAD5432" wrote:

I have a column of dates. These dates are stored in the cell as "112482" and
the cell is formatted as "00\/00\/00" so that in the cell it looks like:
"11/24/82".

The problem is, I can't sort these dates because they are not stored
correctly in the cell for Excel to recognize them like it should. For
instance, "112482" is seen by Excel as 112,482nd day after January 1st, 1900
or 12/18/2007.

It appears there is no function in Excel currently to format my dates
correctly so it can be sorted by Excel. Can I create one using VBA? What
would it be?

  #3   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 8,651
Default Formatting Dates

Formatting doesn't change the value, it only changes the display.
You'll need to convert the value, for example using
=--TEXT(A1,"00\/00\/00"). You can then sort by the new column.
--
David Biddulph

"MEAD5432" wrote in message
...
I have a column of dates. These dates are stored in the cell as "112482"
and
the cell is formatted as "00\/00\/00" so that in the cell it looks like:
"11/24/82".

The problem is, I can't sort these dates because they are not stored
correctly in the cell for Excel to recognize them like it should. For
instance, "112482" is seen by Excel as 112,482nd day after January 1st,
1900
or 12/18/2007.

It appears there is no function in Excel currently to format my dates
correctly so it can be sorted by Excel. Can I create one using VBA? What
would it be?



  #4   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 698
Default Formatting Dates

If you don't mind converting those values directly to dates....

Try this:
Select the vertical range of values

From the Excel main menu:
<data<text-to-columns
....click [Next] until Step 3 of 3
Set the "Column data format" to: Date MDY
Click [Finish]

Example:
These values
112482
60107
123105

Become these:
11/24/1982
6/1/2007
12/31/2005

Does that help?
***********
Regards,
Ron

XL2002, WinXP


"MEAD5432" wrote:

I have a column of dates. These dates are stored in the cell as "112482" and
the cell is formatted as "00\/00\/00" so that in the cell it looks like:
"11/24/82".

The problem is, I can't sort these dates because they are not stored
correctly in the cell for Excel to recognize them like it should. For
instance, "112482" is seen by Excel as 112,482nd day after January 1st, 1900
or 12/18/2007.

It appears there is no function in Excel currently to format my dates
correctly so it can be sorted by Excel. Can I create one using VBA? What
would it be?

  #5   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 22,906
Default Formatting Dates

Select the column with the numbers.

DataText to columnsNextNextColumn Data FormatDateMDYFinish


Gord Dibben MS Excel MVP

On Thu, 28 Jun 2007 08:46:04 -0700, MEAD5432
wrote:

I have a column of dates. These dates are stored in the cell as "112482" and
the cell is formatted as "00\/00\/00" so that in the cell it looks like:
"11/24/82".

The problem is, I can't sort these dates because they are not stored
correctly in the cell for Excel to recognize them like it should. For
instance, "112482" is seen by Excel as 112,482nd day after January 1st, 1900
or 12/18/2007.

It appears there is no function in Excel currently to format my dates
correctly so it can be sorted by Excel. Can I create one using VBA? What
would it be?




  #6   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 28
Default Formatting Dates

That works. Here is a supplemental question for you:

The function works for dates that have double digit months. Single digit
months (January - September) don't have a "0" in front of the month making
the formula return the wrong date.

Example:

4/17/07 is in the spreadsheet as "41707". Due to the cell format, a "0" is
automatically added. Using =DATE(RIGHT(A1,2),LEFT(A1,2),MID(A1,3,2)) in a
date formatted cell gives me "07/09/10". If I add a "0" in front of "41707",
it gives me the correct result but since the spreadsheet has about 5,000
rows, I can't readily devote that much time.

Thoughts?

"Toppers" wrote:

In a helper column format as DATE

=DATE(RIGHT(A1,2),LEFT(A1,2),MID(A1,3,2))



"MEAD5432" wrote:

I have a column of dates. These dates are stored in the cell as "112482" and
the cell is formatted as "00\/00\/00" so that in the cell it looks like:
"11/24/82".

The problem is, I can't sort these dates because they are not stored
correctly in the cell for Excel to recognize them like it should. For
instance, "112482" is seen by Excel as 112,482nd day after January 1st, 1900
or 12/18/2007.

It appears there is no function in Excel currently to format my dates
correctly so it can be sorted by Excel. Can I create one using VBA? What
would it be?

  #7   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 698
Default Formatting Dates

To easily simulate a helper column function..

With A1: A3 containing these values
112482
60107
123105

Select A1:A3
<data<text-to-columns
....click [Next] until Step 3 of 3
Set the "Column data format" to: Date MDY
Set Destination to: C1
Click [Finish]

The values will be converted to dates beginning in cell C1, without writing
over the original data.

Does that help?
***********
Regards,
Ron

XL2002, WinXP


"MEAD5432" wrote:

That works. Here is a supplemental question for you:

The function works for dates that have double digit months. Single digit
months (January - September) don't have a "0" in front of the month making
the formula return the wrong date.

Example:

4/17/07 is in the spreadsheet as "41707". Due to the cell format, a "0" is
automatically added. Using =DATE(RIGHT(A1,2),LEFT(A1,2),MID(A1,3,2)) in a
date formatted cell gives me "07/09/10". If I add a "0" in front of "41707",
it gives me the correct result but since the spreadsheet has about 5,000
rows, I can't readily devote that much time.

Thoughts?

"Toppers" wrote:

In a helper column format as DATE

=DATE(RIGHT(A1,2),LEFT(A1,2),MID(A1,3,2))



"MEAD5432" wrote:

I have a column of dates. These dates are stored in the cell as "112482" and
the cell is formatted as "00\/00\/00" so that in the cell it looks like:
"11/24/82".

The problem is, I can't sort these dates because they are not stored
correctly in the cell for Excel to recognize them like it should. For
instance, "112482" is seen by Excel as 112,482nd day after January 1st, 1900
or 12/18/2007.

It appears there is no function in Excel currently to format my dates
correctly so it can be sorted by Excel. Can I create one using VBA? What
would it be?

  #8   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 2,202
Default Formatting Dates

That works. Here is a supplemental question for you:

The function works for dates that have double digit months. Single digit
months (January - September) don't have a "0" in front of the month making
the formula return the wrong date.

Example:

4/17/07 is in the spreadsheet as "41707". Due to the cell format, a "0"
is
automatically added. Using =DATE(RIGHT(A1,2),LEFT(A1,2),MID(A1,3,2)) in a
date formatted cell gives me "07/09/10". If I add a "0" in front of
"41707",
it gives me the correct result but since the spreadsheet has about 5,000
rows, I can't readily devote that much time.


This should work for you...

=DATE(YEAR("January 1, " &
RIGHT(A1,2)),LEFT(A1,LEN(A1)-4),MID(A1,LEN(A1)-3,2))

Rick

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Formatting of Dates Hervinder Excel Discussion (Misc queries) 1 June 25th 07 10:35 AM
Formatting Dates Jordan Excel Worksheet Functions 4 February 13th 07 12:31 AM
formatting dates Papa Jonah Excel Worksheet Functions 2 September 13th 05 10:42 PM
Dates Not Formatting as Dates awacs Excel Worksheet Functions 4 September 13th 05 10:35 PM
Formatting dates rovetrader Excel Worksheet Functions 1 February 14th 05 05:03 PM


All times are GMT +1. The time now is 03:06 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"