1

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;
ROOT
  • 11,363
  • 5
  • 30
  • 45
KRUPA
  • 113
  • 4

1 Answers1

2

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)

Sunil j.p
  • 36
  • 2