Jul 29, 2002 #1 JayDB Programmer Mar 9, 2004 2 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?
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?
Jul 29, 2002 #2 MarcLodge Programmer Feb 26, 2002 1,886 GB Can you extract the date from the timestamp using the DATE function, and then order by that? Marc Upvote 0 Downvote
Oct 7, 2002 #3 CODEMONKEYBRET Programmer Oct 7, 2002 6 GB 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 => Upvote 0 Downvote
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 =>