Our Community is getting an upgrade! To get everything ready for the relaunch, we’ll be placing the site in read-only mode starting September 21st.
We really appreciate your understanding while we get things set up behind the scenes. Catch up on all the exciting details about the move here.
Need help or have questions? Drop us a line at [email protected]

Community Articles

Find and share helpful community-sourced technical articles.
Announcements
Share your experience with Cloudera on G2 and get a $25 Amazon Gift card.
Hi, I'm CLEO! Something exciting is coming to the Community. Stay Tuned!
Labels (2)
avatar

Question: Are there any functions which allow date arithmetic with phoenix?

Answer: this is done as a fraction of a day. e.g. to add 12 hours to a day:
> select now(), now() + (0.5) ; 
+---------------------------------+---------------------------------+
| DATE '2017-06-04 16:55:07.989'  | DATE '2017-06-05 04:55:07.989'  |
+---------------------------------+---------------------------------+
| 2017-06-04 16:55:07.989         | 2017-06-05 04:55:07.989         |
+---------------------------------+---------------------------------+
To add 15 minutes you would use (15/1440). ie.
0: jdbc:phoenix:> select now(), now() + (0.010416666666667) ;
+---------------------------------+---------------------------------+
| DATE '2017-06-04 16:56:31.492'  | DATE '2017-06-04 17:11:31.492'  |
+---------------------------------+---------------------------------+
| 2017-06-04 16:56:31.492         | 2017-06-04 17:11:31.492         |
+---------------------------------+---------------------------------+
1 row selected (0.024 seconds)
See also: RMP-9148 "Provide Date arithmetic functions for Phoenix"
5,007 Views
0 Kudos
Version history
Last update:
‎06-11-2017 09:48 AM
Updated by:
Contributors