[PHP & MySQL]Sorteren op datum, zo goed?

Pagina: 1
Acties:

Onderwerpen


Acties:
  • 0 Henk 'm!

Verwijderd

Topicstarter
Na asp redelijk te beheersen ben ik nu bezig met php, en ik ben bezig een forum te maken.
Nu wil ik de topics ordenen op datum van laatste reply, en daarvoor heb ik alvast een testje gemaakt:

Database:
dag | maand | jaar | uur | min | sec

Query:
SELECT * FROM datum_test ORDER BY jaar DESC, maand DESC, dag DESC, sec DESC, min DESC, uur DESC"

Resultaat:
Vorgolde in database:
17:4:12 5-12-3
18:12:14 13-5-2
7:10:30 12-4-3
15:30:10 5-12-2
Na ordening:
17:4:12 5-12-3
7:10:30 12-4-3
15:30:10 5-12-2
18:12:14 13-5-2

Dit werkt natuurlijk allemaal wel, maar ik vraag me af of hier geen makkelijkere manier voor is...

Acties:
  • 0 Henk 'm!

  • drm
  • Registratie: Februari 2001
  • Laatst online: 09-06 13:31

drm

f0pc0dert

Euh, wat dacht je van een native datumtype (datetime, date, timestamp, noem maar op) te gebruiken in MySQL?
zie de manual

Music is the pleasure the human mind experiences from counting without being aware that it is counting
~ Gottfried Leibniz


Acties:
  • 0 Henk 'm!

  • thomaske
  • Registratie: Juni 2000
  • Laatst online: 17-09 07:55

thomaske

» » » » » »

Je hebt in MySQL het veld-type Datetime, dan hoef je niet voor iedere datum 6 (!) velden te gebruiken..

zie de manual

edit:

Nu met link erbij! :P

[ Voor 33% gewijzigd door thomaske op 18-12-2002 13:10 ]

Brusselmans: "Continuïteit bestaat niet, tenzij in zinloze vorm. Iets wat continu is, is obsessief, dus ziekelijk, dus oninteressant, dus zinloos."


Acties:
  • 0 Henk 'm!

  • drm
  • Registratie: Februari 2001
  • Laatst online: 09-06 13:31

drm

f0pc0dert

spuit elf :/ :P

Music is the pleasure the human mind experiences from counting without being aware that it is counting
~ Gottfried Leibniz