By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,226 Members | 1,027 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,226 IT Pros & Developers. It's quick & easy.

Problem comparing dates with VARCHAR type

P: 1
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!
Oct 15 '07 #1
Share this Question
Share on Google+
1 Reply


P: 14
Use like this

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

Post your reply

Sign in to post your reply or Sign up for a free account.