Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Rhinorhino on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How do I...Perpetual calendars

Status
Not open for further replies.

Shrum

Programmer
Joined
May 17, 2002
Messages
122
Location
US
I have a collection of entries in what I'm using as a perpetual events listing (no year data) in a table with 2 *text* (yes, text) fields structured like this:

-----EVENTS---------
date | event
-----|---------------
0324 | Sean's B-Day
0704 | Independence Day
1224 | Christmas
-------------------

What I want to do is display all events with the most current one first and the remainder after. The problem I have starts at the end of the year...the list will only go up to the '1224' entry based on my current SQL statments. The list I want to display should look like:

date | event
-----|---------------
1224 | Christmas
0324 | Sean's B-Day
0704 |

I just don't know the SQL (or term) for this sort of sorting. Can someone tell me what the SQL statement is for dealing with 'text' based fields of this nature and operation?

TIA

=============================
Sean Shrum
Shrum Consulting
C.A.T.S.: Consulting: Programming: R/C Soaring:
 
Never mind the sample above as I think most people might be confused by it...Let me change the scenario around.

Let's say I have a list of names that I want to sort starting the list with names that start with 'h'. I want the list to continue thru to 'z' and then continue with the remaining 'a' thru 'g' at the end of the list.

Possible?

TIA

=============================
Sean Shrum
Shrum Consulting
C.A.T.S.: Consulting: Programming: R/C Soaring:
 
How about:
[tt]
SELECT name
FROM tbl
ORDER BY (ASCII(UPPER(name))-ASCII('H')+26)%26
[/tt]


-----
ALTER world DROP injustice, ADD peace;
 
Sorry, that should really be:
[tt]
SELECT name
FROM tbl
ORDER BY
CONCAT(
CHAR(
(ASCII(UPPER(name))-ASCII('H')+26)%26
+ASCII('A')
),
name
)
[/tt]


-----
ALTER world DROP injustice, ADD peace;
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top