0
votes

I have the following query and would like to extract the year from login_time. login_time is in timestamp format (i.e. 2019-03-12 08:51:35.000)

Select year(from_unixtime(cast(login_time as int))) from profile limit 100

There is an error - cannot cast timestamp to integer when I run this query. Does anyone know what's the reason for it? Would appreciate any advice!

1

1 Answers

1
votes

There is an error - cannot cast timestamp to integer

This suggests the login_time is of timestamp data type, so you should just call year() on it:

year(login_time)