Problem comparing dates with VARCHAR type

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • RiotZamber
    New Member
    • Oct 2007
    • 1

    Problem comparing dates with VARCHAR type

    Hi, I'm new to DB2 so I apologize if this is a dumb question. :)

    I have this table with 2 columns

    col_date (varchar(8)) (eg. 20070813) (yyyyMmdd)
    col_time (varchar(6)) (eg. 1525) (HHmm)

    I have to write a query to select data larger than some date and the problem is my 2 columns are of type varchar

    I tried to do something like this..

    SELECT * FROM blah WHERE CAST(CONCAT(col _date, col_time) AS INTEGER) > 200708081538

    but it doesn't seem to work.. it seems I can't put the CONCAT function inside CAST for some reason...

    thanks for any help!
  • dewa81
    New Member
    • Jul 2007
    • 14

    #2
    Use like this

    SELECT * FROM blah WHERE TIMESTAMP(DATE( col_date), TIME(col_time)) > '2007-08-08 15:38:00'

    Comment

    Working...