Addtime function is not working

Hi team,

I am migrating my existing project from Mysql to CockroachDB. I am facing some issue with “addtime” function. Can anyone suggest the alternative for below query.

ADDTIME(start_at, SEC_TO_TIME(duration*60))

Error: Undefined function: 7 ERROR: unknown function: addtime()

Hey @kishoresai438,

I can suggest utilizing our interval data type, the docs are here.

In your case, you would want to convert SEC_TO_TIME(duration*60) to an interval.

The supported time formats are listed in the docs.

The interval data type can also be cast, see below.

Example query with type casting:

SELECT now() + <time_to_add>::interval;

Let me know if this works for you!


Hi Matt,

Sorry for the late response. the above syntax is working fine. Thank you.

Glad to hear it worked out.

Thanks for the reply.