0
votes

need help in below problem: I am using Hive UI, I have to minus 1 minute from date-time (string)

(2019-03-29 00:00 - 1 min)

below is not working:

         DATEADD(minute,-1, cast(first_value(colt.start_date) over
                                   (partition by table.period,table.model_name
                                     order by table.start_date desc
                                     rows between unbounded preceding and current row
                                   ) as timestamp
                                 )
                )

or

date_add(FROM_UNIXTIME(UNIX_TIMESTAMP (first_value(table.start_date)over (partition by
table.ytd_glperiod,table.model_name order by table.start_date desc
rows between unbounded preceding and current row
),"yyyy-MM-dd HH:mm:ss" ) ),-1
)

1

1 Answers

0
votes

To subtract a minute from a value in Hive, use:

<col> - interval '1' minute

This works for more complex expressions as well.