Andy already gave you the answer. I would like to add that you could implement a simple function that does the conversion:
Code:
CREATE FUNCTION strToDate(str VARCHAR(16))
RETURNS DATE
LANGUAGE SQL
DETERMINISTIC
CONTAINS SQL
RETURN DATE(substr(str, 4, 2) || '/' || substr(str, 6, 2) || '/20' || substr(str, 2, 2));
No you can simplify your query to:
Code:
SELECT strToDate(endTime) AS endtime
FROM warehouselog
WHERE strToDate(endTime) >= CURRENT TIME
Note: you should
really reconsider your column alias ENDTIME. You return a date and not a time value. Thus, the chosen alias is wrong and confusing.
p.s: Have a look at the DB2 manual (or the SQL standard if you prefer) to understand the differences between TIMESTAMP, DATE, and TIME values.
Converting a timestamp to a date does not make much sense.
Extracting the date portion from a timestamp does.