Results 1 to 8 of 8

Thread: sorting dates

  1. #1
    Join Date
    Feb 2005
    Posts
    41

    Unanswered: sorting dates

    Generally speaking, say using normal SQL if u wanted to sort month names in correct order how would u do it???

  2. #2
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    Code:
    order by
      position( lower(substring(monthname from 1 for 3))
             in 'janfebmaraprmayjunjulaugsepoctnovdec' )
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

  3. #3
    Join Date
    Feb 2005
    Posts
    41
    thanks

    do u no if there is similar to this mdx???

  4. #4
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    no, i don't, if you recall i actually had to google up what MDX was just the other day

    you seem to have been struggling with MDX for a long time

    have you considered going to microsoft for help?

    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

  5. #5
    Join Date
    Feb 2005
    Posts
    41
    ooooppppsss

    soz m8... yeah im doing this for days and seem to be getting more confused than finding a solution....

    what i dont get is ever system has the month / week no sorted, there must sumwhere i can get the answer from : (

    thanks enyways

  6. #6
    Join Date
    Jun 2003
    Location
    Ohio
    Posts
    12,592
    Provided Answers: 1
    Perhaps you should retain the original date value in your dataset in addition to it's equivalent month name. Then DISPLAY the month name, but SORT by the actual date value...
    If it's not practically useful, then it's practically useless.

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

  7. #7
    Join Date
    Jan 2003
    Location
    Massachusetts
    Posts
    5,800
    Provided Answers: 11
    Position?

    I am not familiar with this function. Are you sure it is a microsoft function? Although, I don't know MDX. Every time I google for it, I get ads for some kind of minvan.

  8. #8
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    Quote Originally Posted by MCrowley
    Position?

    I am not familiar with this function. Are you sure it is a microsoft function? Although, I don't know MDX. Every time I google for it, I get ads for some kind of minvan.
    clearly you are a google novice

    asbir asked me for "normal"

    can't think of anything more normal than standard sql

    furthermore, there was the "if u wanted" qualifier, and standard sql is how i would want to do it

    i thought it was a reasonable answer, in spite of the fact that it would have to be translated into sql server's proprietary functions

    the idea is that you use the left three characters of the month name as a substring index into a string of twelve 3-char month names to get a location and that numeric position is what you ORDER BY on to put month names into their correct chronological sequence

    sorry if it confused anyone

    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

Posting Permissions

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