1
votes

In presto, I have a date formatted as varchar that looks like below :

 10:46:00

I need to cast this in timestamp. I have tried few but presto throwing errors as

Value cannot be cast to date:10:46:00 and Value cannot be cast to timestamp:10:46:00

select cast('10:46:00' as DATE) from abc;

select cast('10:46:00' as TIMESTAMP) from abc;
1
so what is the output of your sample data - Zaynul Abadin Tuhin

1 Answers

2
votes

Try with the below query it will solve your problem.

Input Query in Presto:

select (hour(date_parse(CheckStartTime,'%T')) + 1) as hr from TableName;

CheckStartTime:

Column name(varchar) of the table in the format of '12:32:20'.

Output:

13 (it will add one hour to the input time)