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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

DB2 Order By limitations

Status
Not open for further replies.

JayDB

Programmer
Mar 9, 2004
2
0
0
US
I need to order my results by the date portion of a timestamp column. Using the SUBSTR on the ORDER BY clause does not work. What does?
 
Can you extract the date from the timestamp using the DATE function, and then order by that?
Marc
 
Like this...?

db2 => select * from dtest

THETIME
--------------------------
2002-10-07-17.47.57.666000
2002-10-07-17.47.59.058000
2002-10-07-17.47.59.479000
2002-10-06-17.56.43.642000
2002-10-05-17.56.51.253001
2002-10-07-15.56.58.744001

6 record(s) selected.

db2 => select date(thetime) as a from dtest order by a

A
----------
10/05/2002
10/06/2002
10/07/2002
10/07/2002
10/07/2002
10/07/2002

6 record(s) selected.

db2 =>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top