Home » SQL & PL/SQL » SQL & PL/SQL » SQL DateTime
SQL DateTime [message #20502] Thu, 30 May 2002 09:50 Go to next message
dc
Messages: 6
Registered: May 2002
Junior Member
How can I get this query to sort by date and time correctly?
SELECT received_status_code status
, count(doc_num) pages
, entered_by
, TO_DATE(log_in_ts, 'DD-MON-YY HH:MI')
FROM RECEIVED_DOC
WHERE PROJECT_ID = '111'
and entered_by = 'OPS$X'
group by entered_by
, received_status_code
, TO_DATE(log_in_ts, 'DD-MON-YY HH:MI')

--sample
01-MAY-02 03:02 ---> is PM
01-MAY-02 09:00
01-MAY-02 11:12

Thanks,

DC
Re: SQL DateTime [message #20506 is a reply to message #20502] Thu, 30 May 2002 11:29 Go to previous messageGo to next message
Todd Barry
Messages: 4819
Registered: August 2001
Senior Member
To have the rows sort correctly, just add an ORDER BY clause to your query:

order by log_in_ts


However, you might want to consider also changing your format mask on your date displays to include am/pm so you can distinguish these times:

'DD-MON-YY HH:MIam' or 'DD-MON-YY HH24:MI'
Re: SQL DateTime [message #20509 is a reply to message #20506] Thu, 30 May 2002 11:51 Go to previous messageGo to next message
dc
Messages: 6
Registered: May 2002
Junior Member
Todd thanks for the quick reply.
Sql DateTime Qry [message #21227 is a reply to message #20506] Thu, 18 July 2002 14:24 Go to previous message
Jakman
Messages: 1
Registered: July 2002
Junior Member
Who I can make the next qry, or is that correct???

Select * from Sesionhoy
where fechasi = 17/01/56

where fechasi is a datetime field
Previous Topic: How to delete all the rows from a table?
Next Topic: Net 8 problem
Goto Forum:
  


Current Time: Wed May 08 01:23:50 CDT 2024