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

Sort dates that have double zeroes in the month or day section

In the attached XL sheet, I have a Date column that I want to sort by year. The problem is, for some of the dates, I don't know the exact day or monty, only the year, so I've put a double zero (00) placeholder in there for the days/months I'm not sure of. It needs to be exact so I can't put 01 or anything like that in there. When I do this, it does not sort correctly. Is there some way to maintain the double zeroes and have the sheet column sort correctly by year?

Thanks,
Sort-Date.xlsx
0
contrain
Asked:
contrain
2 Solutions
 
SimonCommented:
Short answer: NO.

day of month = 00 is not a valid date and the cell becomes a text entry.

I'd suggest you use a default of 01 (first of the month) and add a column next to it with a flag to indicate uncertainty over the exact date.

>It needs to be exact
It just can't be exact all the time you have unknowns in there.

I suppose the other thing you could do would be to use a =Year(yourdatecolumn) formula to get the year on its own, though you'd manually have to enter the year for the non-date 00 entries that you added. You could then sort on that Year column.
0
 
FlysterCommented:
Here's a round about way. This formula is used to determine the year:

=VALUE(IF(ISTEXT(A2)=TRUE,RIGHT(A2,4),YEAR(A2)))

It can be done without the Value function as it did not sort like I thought. Basically what it does is look at your data to determine if it text or not. If it is, it uses the Right Function. If not then it uses Year. Do the same for Month and Day, using the appropriate functions:

=IF(ISTEXT(A2)=TRUE,LEFT(A2,2),MONTH(A2)) for month and
=VALUE(IF(ISTEXT(A2)=TRUE,MID(A2,4,2),DAY(A2))) for day.

Once that's done, copy all the data and then paste it special as values on another sheet. (See Sheet2 of attached.) You can now sort on that data.

Flyster
Sort-Date.xlsx
0
 
Rob HensonFinance AnalystCommented:
Flyster - you don't need the =TRUE part of those formulas. The IF statement will deal with the TRUE and FALSE conditions.
0
Cloud Class® Course: Microsoft Windows 7 Basic

This introductory course to Windows 7 environment will teach you about working with the Windows operating system. You will learn about basic functions including start menu; the desktop; managing files, folders, and libraries.

 
Rob HensonFinance AnalystCommented:
I have found that some of the text entries have a spare space character at the end.

I have tried incorporating the TRIM function with Flysters suggestions and it all goes horribly wrong.
0
 
Rob HensonFinance AnalystCommented:
Year - =IF(ISTEXT($A2),RIGHT(TRIM($A2),4),YEAR($A2))
Month - =IF(ISTEXT($A2),MID(TRIM($A2),4,2),MONTH(TRIM($A2)))
Day - =IF(ISTEXT($A2),LEFT(TRIM($A2),2),DAY(TRIM($A2)))

Don't need to copy and paste, can sort in place by year then month then day.

I think it was going wrong because I was putting a TRIM around the first A2 as well "ISTEXT(TRIM($A2))" and by forcing a function on what looks like a date, Excel was trying to convert to a date, incorrectly in places.

Thanks
Rob H
0
 
Rob HensonFinance AnalystCommented:
Just noticed, Flyster's suggestions have assumed date format mm/dd/yyyy whereas I have assumed date format dd/mm/yyyy.

The cell format of sample data would suggest mm/dd/yyyy to be correct so my formulas should be:

Year - =IF(ISTEXT($A2),RIGHT(TRIM($A2),4),YEAR($A2))
Month - =IF(ISTEXT($A2),LEFT(TRIM($A2),2),MONTH(TRIM($A2)))
Day - =IF(ISTEXT($A2),MID(TRIM($A2),4,2),DAY(TRIM($A2)))

Thanks
Rob H
0
 
contrainAuthor Commented:
I am accepting and giving points to 2 answers because each gave me what I wanted even though there were slight differences on the formulas used. Great answers both to a very difficult situation!
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

Cloud Class® Course: Microsoft Exchange Server

The MCTS: Microsoft Exchange Server 2010 certification validates your skills in supporting the maintenance and administration of the Exchange servers in an enterprise environment. Learn everything you need to know with this course.

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