Why does Explorer ignore seconds when sorting by Date Modified?


A customer reported that Explorer appears to be ignoring the seconds when sorting by Date Modified. The customer was kind enough to include detailed steps to reproduce the problem.

Start with a folder with several files, sorted by Date Modified.

Name Date modified Type
TPS 06-05-2012 Report 6/12/2012 7:00 AM Contoso Document
TPS 05-29-2012 Report 6/5/2012 11:30 AM Contoso Document
TPS 05-22-2012 Report 5/29/2012 10:17 AM Contoso Document
TPS 05-15-2012 Report 5/22/2012 2:35 PM Contoso Document
TPS 05-09-2012 Report 5/15/2012 11:26 AM Contoso Document
TPS 05-02-2012 Report 5/9/2012 10:31 AM Contoso Document

Right-click on the newest file, select Copy.

Right-click on the blank column on the right, select Paste. This will create a file with the same name, but with "- Copy" appended.

Press F5 to refresh the view and note the sort order. The copy appears at the top of the list.

Name Date modified Type
TPS 06-05-2012 Report - Copy 6/12/2012 7:00 AM Contoso Document
TPS 06-05-2012 Report 6/12/2012 7:00 AM Contoso Document
TPS 05-29-2012 Report 6/5/2012 11:30 AM Contoso Document
TPS 05-22-2012 Report 5/29/2012 10:17 AM Contoso Document
TPS 05-15-2012 Report 5/22/2012 2:35 PM Contoso Document
TPS 05-09-2012 Report 5/15/2012 11:26 AM Contoso Document
TPS 05-02-2012 Report 5/9/2012 10:31 AM Contoso Document

Highlight the newly-created file, hit F2, and give the document a different name, and also remove the "- Copy" suffix. Hit Enter to accept the operation.

Press F5 to refresh the view again. Notice that the file that you just renamed, which is the newest file in the folder (it having just been created seconds ago) appears second in the list.

Name Date modified Type
TPS 06-05-2012 Report 6/12/2012 7:00 AM Contoso Document
TPS 06-12-2012 Report 6/12/2012 7:00 AM Contoso Document
TPS 05-29-2012 Report 6/5/2012 11:30 AM Contoso Document
TPS 05-22-2012 Report 5/29/2012 10:17 AM Contoso Document
TPS 05-15-2012 Report 5/22/2012 2:35 PM Contoso Document
TPS 05-09-2012 Report 5/15/2012 11:26 AM Contoso Document
TPS 05-02-2012 Report 5/9/2012 10:31 AM Contoso Document

It appears that Explorer is ignoring the seconds in the Date Modified column and sorting only by the hour and minute.

It's an interesting theory the customer came up with, but the customer was fooled by the fact that he ran the experiment shortly after modifying the TPS 06-05-2012 Report document, so that the real behavior was masked.

When you copy a file, the system preserves the date-modified timestamp. The Date modified column is not ignoring the seconds; in fact, it's comparing them quite carefully, but since the timestamps of the original and the copy are the same, the timestamps compare equal. And when the items compare equal according to the sort criteria, Explorer falls back to sorting by name, and the fallback sort is always ascending.

The confusion would have been cleared up if the Date modified column used the long time format instead of the short time format, but that only pushes the problem to files whose timestamps are fractional seconds apart. You have two files which show up as "6/12/2012 7:00:12 AM" and don't realize that one of them is "6/12/2012 7:00:12.02 AM" and the other is "6/12/2012 7:00:12.89 AM". My guess is that geeks won't be satisfied until Explorer shows the full 64-bit FILETIME so you can see the difference down to the 100-nanosecond interval.

(If you want to see the seconds, you can look on the file's property sheet.)

Comments (39)
  1. Adam Rosenfield says:

    "[…] but since the timestamps of the original and the copy are the same, the timestamps compare equal" is another one of those "I can't believe you had to write that" statements.

  2. John says:

    [The confusion would have been cleared up if the Date modified column used the long time format instead of the short time format, but that only pushes the problem to files whose timestamps are fractional seconds apart.]

    This argument is invalid because XP shows the seconds and Vista does not, meaning somebody somewhere made a conscious design decision to remove existing functionality.

  3. Simon says:

    "[…](If you want to see the seconds, you can look on the file's property sheet.)"

    This might work for 'older' files, but a new file will only show something like "Created 2 minutes ago" in Windows 7.

    It would be great to reenable the old Windows XP behaviour on timestamps in the explorer via some kind of registry hack, but this doesn't seem to be possible…

  4. Mike Caron says:

    "My guess is that geeks won't be satisfied until Explorer shows the full 64-bit FILETIME so you can see the difference down to the 100-nanosecond interval."

    No, they won't be satisfied until Windows uses a new arbitrary precision date format to store dates as a multiple of the Planck time (en.wikipedia.org/…/Planck_time) (offset from the date of the Big Bang, of course).

  5. Joshua says:

    Most people who do not know that copy copies the modification time don't know that FILETIME is more precise than seconds so there would be astoundingly low chance of that not solving the problem right there.

  6. @Mike Caron; geez, it looks like even 128-bit integers won't have the necessary granularity (we're at about 1.4 * 2^184 Planck times since the Big Bang if I calculate this right.)

  7. jader3rd says:

    To continue on what Simon said, a Folder Option to show timestamp instead of Minutes ago would be great.

  8. xpclient says:

    Pls fix forced auto sorting in Explorer and make it optional. Files jumping on rename, copy-paste, extraction or creation make Explorer unusable.

  9. dave says:

    This might work for 'older' files, but a new file will only

    show something like "Created 2 minutes ago" in Windows 7.

    Why an option? Why not show both?  The propsheet doesn't seem short of space.

  10. xpclient says:

    Your instructions to press F5 to refresh the view are unnecessary as there is no way in Windows 7/Vista to not refresh/treating sorting as a verb. It's always refreshed and it's always sorted.

  11. No One says:

    @Mike Caron, Re: Y10K/Planck time.  I think we need even better granularity than that.  The problem is that you can have two files created at the same Planck time.  Or, at least, their metadata could state as much.  I think we need at least a 1024-bit GUTS (Globally-unique timestamp) system.  The guts of GUTS would be, essentially, a monotonic clock of events in the universe.  Now, we get into a problem of two events that cannot be ordered stably in all frames of reference, so we'd have to choose an appropriate frame of reference of course.  The beauty of the system would be that every file, syslog event, birthdate, death and TV show air time would be given a unique 1024 bit number.

    Now, I figure 1024 bits should be enough because a 256 bit timestamp should handle Planck time through the existence of the universe and the additional 768 bits could be disambiguators.  We would, however, need a central server to coordinate the timestamping.  I figure once quantum computing is up and running in five or ten years we can just put quantum clients everywhere to handle this though.  That should be trivial once we hash out a new RFC.

  12. alegr1 says:

    I believe there is a setting to disable "friendly" file modification display in Win7, as my work installation of Win7 enterprise shows files' modification dates in full format. Maybe it's only enabled in the Home SKU?

  13. Rangoric says:

    @xpclient you do realize this post was created 2-3 years ago right? And might be referring to something that happened ever further in the past?

  14. Willie says:

    And instead people should not date their files with MM-DD-YYYY if you are going to put the date in the filename.  Date it as YYYY-MM-DD and it self sorts.

    I realize this has nothing to do with the original "problem"

  15. Tud says:

    @No One: a single, global time across the universe? Some guy called Albert E. would like to have a word with you.

  16. No One says:

    @Tud: I handled that — need a defined reference frame to consider as the basis.  Also, whoosh?  But for which one of us?

  17. Calculating a little more carefully:

    1 Planck time = 5.4e-44 seconds

    Age of universe = 1.37e10 years * (365.242 days/year) * (24 hours/day) * (60 minutes/hour) * (60 seconds/minute) / (5.4e-44 Planck times/second) = 8.01e60 Planck times

    log10(age of universe in Planck times) = 60.9

    so log2(age of universe in Planck times) = log10(age of universe in Planck times) / log10(2) = 202.3

    So we need 202-203 bits just to store current time stamps.  But we should of course future-proof the design; perhaps we should invoke RFC 2550 dates (with particular attention paid to section 2.4.2)

    tools.ietf.org/…/rfc2550

  18. AC says:

    @Maurits:

    This is priceless:

    >3.4 Years 10 ** 30 and beyond (Y10**30)

    >

    >   As discussed in 2.4.1, the end of the universe is predicted to occur

    >   well before the year 10 ** 30.  However, if there is one single

    >   lesson to be learned from the current Y2K problems, it is that

    >   specifications and conventions have a way of out living their

    >   expected environment.  Therefore we feel it is imperative to

    >   completely solve the date representation problem once and for all.

  19. GOD DAMN IT ! says:

    This comment system is buggy and eats comments, is it using .net crap ?

  20. Mr Planet says:

    @No one special

    shell extension can do that, convert filetime to what ever and display it

    Star trek stardate is based julian date system

    Links:

    http://www.youtube.com/watch

    en.wikipedia.org/…/Julian_date

  21. SomeGuyOnTheInternet says:

    What I'd like to know is why a mixture of filenames in YYYYMMDD and YYYYMMDDHHMM format sort in two different groups in Windows 7:

    20120301.txt

    20120302.txt

    20120303.txt

    20120304.txt

    201203031200.txt

    201203031330.txt

    I would have thought the file 20120304.txt should be at the bottom, not in the middle.

  22. Mr Planet says:

    btw Mr chen should do more blog posts about shell programming.

    Like drag and drop. Many programs does it wrong even internet explorer. In windows 7. Try dragging a url from it to chrome and see the desktop and taskbar icons flash and a performance drop (lag, mouse stops responding for about half a second while dragging url). ( And thats on an intel i7 gaming machine, nice job ie team ! Did you work on vista too ? )

  23. lol says:

    @Mr Planet

    Talking about vista reminds me of windows 8. Windows 8 is vista but with a tablet twist. Windows 8 is unusable on a normal keyboard and mouse computer.

    No start button !!

    No more win key, type app name and enter key :(

    Windows 8 is a design disaster for computer users equal to how vista was a performance disaster.

    Who's to blame for these retarded and obviously really bad design decisions ?

    Thinking that what does not work for windows phone will work for a computer user.

    They might work for tablet with touch but NOT for computers with keyboards and mouse.

    I always start to rant when talking about how stupid microsoft can be.

    It really irks me, so many work at microsoft and no one are saying how bad this will be for computer users ?!

  24. another net surfer says:

    @SomeGuyOnTheInternet

    "I would have thought the file 20120304.txt should be at the bottom, not in the middle."

    I do not think explorer use natural sorting. If it does then the algorithm is broken like so many other things in windows.

  25. GregM says:

    "What I'd like to know is why a mixture of filenames in YYYYMMDD and YYYYMMDDHHMM format sort in two different groups in Windows 7:

    20120304.txt

    201203031200.txt"

    These are (or look like) numbers, so they sort numerically, and 20 million is less than 201 billion.

  26. Drak says:

    @Mr Planet: On this here I5 work PC there's no noticable icon flashes, mouse lags or anything else when I drag URLs from IE9 to Chrome… Don't know what you've done to your gaming machine, but I doubt it's good for it.

  27. No one special says:

    In general relativity, there is no such thing as an inertial reference frame – relative velocities only make sense for point particles at the same point of spacetime.

    And having said that, can we please have timestamps in Star Trek stardate format (with *lots* of decimal points).

    Anyways, maybe a generic framework can be designed for the next version of Windows where users can create/install add-ins that provide hooks that explorer calls to provide date sorting. A dialog box can be shown every time explorer is launched that allows the user to pick their date sorting preference (with the previous choice being the default, for usability). This would have the advantage of pleasing everybody: those who believe the universe is 13+ billion years old, those who believe it's 6000 years old, those who believe it's as old as they are, those who just want to sort by Created Date instead of Modified Date…

  28. ender says:

    @GOD DAMN IT !:

    AFAIK, it's Community Server, which was not designed to be used: forums.thedailywtf.com/…/279102.aspx

  29. Ooh says:

    Obligatory Raymond Chen reference:

    Windows Confidential: The Evolution of Sorting

    technet.microsoft.com/…/hh475812.aspx

  30. xpclient says:

    @Rangoric Given that the article talks of "- Copy" being appended, he's talking about Vista/7 which, the first one of which was released 5 years ago ever since when we have had the auto sorting problem in Explorer. :)

  31. KS says:

    concerning the various comments about preferred sorting in Explorer. There's a registry switch for Explorer which allows to switch between two sorting algorithms. I don't remember in detail, a Google search will tell you more.

  32. John says:

    @GOD DAMN IT !:  Yep.  If it takes you longer than a certain amount of time to hit the Post button then your comment silently gets lost.  It happened to me so often that I've now gotten into the habit of copying my comment before submitting just to be safe.

    @lol:  Yep.  I suspect there are two (or more) factions within Microsoft and the wrong one (from our perspective) came out on top.  I can't imagine any Microsoft developers actually like doing development work on Windows 8.  The transition from the "classic" desktop to the Start screen is far too jarring for my tastes.  The "workaround" is to pin your most used apps to the taskbar, but there's only so much room.  Probably better to create a toolbar with all your apps, but at that point you've gone and reinvented the "classic" Start menu.  Mind boggling, really.

  33. @KS says:

    You are referring to changing the sort order of numerals. And the comments was referring to the completely different problem of Vista/7 always keeping files sorted which makes monitoring folders for new files or sequentially renaming multiple files a usability nightmare. Or copy-pasting multiple files and if you want to do something else with them after the paste, change their selection or extracting many files into a folder already containing many files etc. Apparently, it's by design and MS is too arrogant about making it optional. It's a serious usability flaw in Explorer.

    [Ah, the checkbox, the mating call of the loser. -Raymond]
  34. You can turn off the numeric sort in Explorer as follows:

    Elevated command prompt | gpedit.msc | Local Computer Policy

       User Configuration | Administrative Templates | Windows Components

           Windows Explorer | Turn off numerical sorting in Windows Explorer (enable)

    Besides the YYYMMDD vs. YYYYMMDDHHMMSS problem, this also causes issues if you have a directory with a bunch of entries that have GUIDs in their names.

  35. Joshua says:

    I have to agree with KS. I hardly use Explorer for file management anymore. Loss of the context made the command prompt simply more efficient.

  36. John says:

    [Ah, the checkbox, the mating call of the loser. -Raymond]

    For some reason this made me imagine you as Blake in that famous scene from Glengarry Glen Ross.

  37. xpclient says:

    The article "The checkbox, the mating call of the loser." is against the very basic principles of UI backward compatibility of Windows from 95 to XP and why it what it is today and why Vista failed. Vista's UX was FAIL (because Jim Allchin who used to force backward compatibility couldn't give a 100% to it and because it removed choice.) Never thought I would have to teach UX to the guy who wrote TweakUI.

  38. Medinoc says:

    ^Seconded. When you change something, some people are going not to appreciate it, and WANT a checkbox to disable it.

  39. alegr1 says:

    THANKS GOODNESS I can still disable "hide extensions of known file types" disastrous setting. Why disastrous? Too many people fell victim of clever viruses disguised as an MP3 or JPEG file, including a friend of mine, who lost his JPG files. I don't care if Raymond calls me a loser for having that checkbox. It's a shame MS UI group still have people who come all the time with such ideas as "search animated character", or "desktop cleanup wizard", or Win8 server control panel (replacement for the management console), or God forbid, Metro.

Comments are closed.

Skip to main content