cast a timestamp value as a time value

Database
Enthusiast

cast a timestamp value as a time value

I have a timestamp field that I want to cast as a time value.

The data in the field values look like this:

2005-12-07 09:32:39

I just want the HH:MM portion of the timestamp.

I tried different variants of select cast(Pe_Sess_Strt_Dt_Tm as time(0) ) from dvu_111.t_pe_offr

The error message is 5407: Invalid operation on an ANSI Datetime or Interval value.
1 REPLY
Enthusiast

Re: cast a timestamp value as a time value

Sheridany,

try this statement:

select Pe_Sess_Strt_Dt_Tm (format 'HH:MI') (varchar(80))

Note that implicit cast (varchar(80)) is necessary to ODBC connections (like sql assistant).