Results 1 to 8 of 8
  1. #1
    Join Date
    Jan 2005
    Posts
    165

    Unanswered: order results by date not working

    hi. i'm trying to order my results ascending by date except i'm getting some really weird output. my ouput resembles something like this:

    oct 2
    oct 3
    sep 13
    sep 21
    sep 22
    sep 30
    aug 3
    aug 5
    aug 16

    the data is stored in a date field. i use getdate when inserting the date to the database. is there a reason why the dates are showing up weird and not ordering appropriately? thanks for your help.

    also, can you not search here any more? i keep getting timeout errors.

  2. #2
    Join Date
    Jun 2003
    Location
    Ohio
    Posts
    12,592
    Provided Answers: 1
    Can you post the code you are using?
    If it's not practically useful, then it's practically useless.

    blindman
    www.chess.com: "sqlblindman"
    www.LobsterShot.blogspot.com

  3. #3
    Join Date
    Jan 2005
    Posts
    165
    Code:
    SELECT Documents.MergeID, Documents.VBKey, Documents.DocumentID, 
    Documents.DateCreated, Documents.[FileName] AS FileNameDesc, 
    DocumentDescription.[Description] AS DocumentDesc FROM Documents 
    LEFT JOIN DocumentDescription ON Documents.DocumentID=DocumentDescription.DocumentID 
    WHERE Documents.VBkey="& vbkey &" AND Documents.DateDeleted IS NULL 
    ORDER BY Documents.DateCreated DESC

  4. #4
    Join Date
    Nov 2003
    Posts
    2,933
    Provided Answers: 12
    Could it be that the dates hav different years in them? You could output the full date to verify that

  5. #5
    Join Date
    Jan 2005
    Posts
    165
    Quote Originally Posted by shammat
    Could it be that the dates hav different years in them? You could output the full date to verify that
    no, the correct years are in there. the only year in there would be 2006 for right now b/c that's when this project got started. thanks for your help though!

  6. #6
    Join Date
    Jan 2005
    Posts
    165
    ok. i just ran this through query analyzer and this is how it's displaying the dates:
    Sep 26 2006 3:10PM

    so, it looks like my dates are being arranged alphabetically???

  7. #7
    Join Date
    Nov 2003
    Posts
    2,933
    Provided Answers: 12
    Quote Originally Posted by bla4free
    so, it looks like my dates are being arranged alphabetically?
    Why do you expect them to be sorted alphabetically?
    They are dates, they will be sorted like dates!

  8. #8
    Join Date
    Nov 2004
    Location
    on the wrong server
    Posts
    8,835
    Provided Answers: 6
    Quote Originally Posted by shammat
    Why do you expect them to be sorted alphabetically?
    They are dates, they will be sorted like dates!
    is this a datetime field?
    “If one brings so much courage to this world the world has to kill them or break them, so of course it kills them. The world breaks every one and afterward many are strong at the broken places. But those that will not break it kills. It kills the very good and the very gentle and the very brave impartially. If you are none of these you can be sure it will kill you too but there will be no special hurry.” Earnest Hemingway, A Farewell To Arms.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •