473,406 Members | 2,387 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

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!
Oct 15 '07 #1
1 2017
dewa81
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

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

Similar topics

19
by: Lauren Quantrell | last post by:
I have a stored procedure using Convert where the exact same Convert string works in the SELECT portion of the procedure but fails in the WHERE portion. The entire SP is listed below....
3
by: Matt | last post by:
Hello, I have a query that I would like to schedule in DTS. The criteria of this query checks for records in the table that are within the current quarter. Here is what I have. WHERE...
3
by: phancey | last post by:
I've got a table (TYPE, DAYMTH) where it is a compound key and the DAYMTH is a datetime but all years are 1900 ONLY THE day and month are significant. What I want to do is for each type, find...
6
by: John | last post by:
Hello, I have an Access DB with a column holding dates from present day back to around year 1702, and I am trying to run DTS Import with this MDB, which fails due to a conversion error. MSDN...
13
by: Jim Armstrong | last post by:
Hi all - This problem has been driving me crazy, and I'm hoping the answer is something stupid I am neglecting to see.... The procedure posted below is part of an Access/SQL database I have...
6
by: fjleon | last post by:
Hi, i have a table with 3 ints that are used to store dates. The datetime data type is not used because this data comes from an old AS400 server. I need to be able to use those 3 columns to...
5
by: iulian.ilea | last post by:
Is correct to have a varchar field and insert dates of type dd/mm/yyyy into it? I choose this method because I have an application that runs on more than one server. So, if I used a datetime field...
1
by: webandwe | last post by:
Hi The code below I took from a postgre file and convert it with a program to a mysql. Once i tried to import it to mysql it gave me an error and when i past in a php file to upload it trough a...
1
Manikgisl
by: Manikgisl | last post by:
But the problem is we have dates in Varchar instead Datetime While Converting Varchar To Datetime All four formats are unable to Convert ie select Convert(Datetime,'18-11-2008 2:35:19...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.