What date operators are supported


#1

I have an Event table with a start_time TIMESTAMP column and a duration Integer column (number of seconds since event started). What I want to calculate is an event finish time = start_time + duration in a query. Clearly SELECT start_time + duration won’t work as there are no units but the error hints at a <DATETIME_INTERVAL> type. There appears to be an INTERVAL keyword but I can see how to actually use it.

Can someone provide some information as to how to use this operator.

Thanks,

Julian


#2

Hi,

INTERVAL is not fully supported yet.

We are adding support currnetly for TIMESTAMPADD and TIMESTAMPDIFF

you will be able to write your query like this

SELECT TIMESTAMPADD(SECONDS,duration, start_time) as end_time FROM TEST1;

in a release coming very soon

Your only option right now is to convert to epoch

SELECT EXTRACT(EPOCH FROM start_time)+duration as end_time FROM TEST1;

depending on if you want to use it a comparator this may work for many use cases

regards


#3

Thanks, that’s great and a perfectly good solution for what we’re doing. Related question: is there a way to go from the calculated value back to a timestamp?


#4

Hi

There is no support for going back from epoch to a timestamp via CAST

regards


#5

Yep, noticed that :slight_smile: Will sort that on the client side. Thanks again