There are plenty of built-in functions available in Apache Impala that helps in analyzing the data and business logic implementations. It relieves a developer’s worries and eliminates the necessity for user-defined functions. Built-in functions aid analysts in the process of analyzing, cleansing, transforming, and modeling data in order to identify valuable information, draw conclusions, and support decision-making.
This is one of a series of articles describing how to use “date-time” functions. We’ll go through how to add and subtract a certain number of minutes from a given date, in this post.
MINUTES_ADD and MINUTES_SUB are the functions that adds and subtracts a specified number of minutes from a TIMESTAMP value. These functions deal with an actual TIMESTAMP value instead of a string that is converted to a TIMESTAMP.
Syntax:
MINUTES_ADD(TIMESTAMP startdate, INT days)
MINUTES_ADD(TIMESTAMP startdate, BIGINT days)
MINUTES_SUB(TIMESTAMP startdate, INT days)
MINUTES_SUB(TIMESTAMP startdate, BIGINT days)
Examples:
SELECT NOW() AS CurrentDate, MINUTES_ADD(NOW(), 30) TimeAfter30Mins;
….—…………CurrentDate…………….|………..–.TimeAfter30Mins–………..
2021-12-02 01:01:42.750309000 | 2021-12-02 01:31:42.750309000
SELECT NOW() AS CurrentDate, MINUTES_SUB(NOW(), 30) TimeBefore30Mins;
….—…………CurrentDate…………….|………..–.TimeBefore30Mins–………..
2021-12-02 01:06:46.864656000 | 2021-12-02 00:36:46.864656000
I hope you found this post to be informative.
Please join our mailing list to receive more interesting information.
2 comments