FROM_TIMESTAMP in Apache Impala

The FROM TIMESTAMP() function converts TIMESTAMP values into arbitrary string formats for reporting purposes. Because Impala implicitly converts string values to TIMESTAMP, you can pass date/time values to this function as strings in the standard yyyy-MM-dd HH:mm:ss.SSS format. As a result, a string with different separator characters, field order, spelled-out month names, or other variations of the date/time string representation is produced.

SELECT FROM_TIMESTAMP(NOW(),’yyyy-mm-dd’);
+——————————————————–+
| from_timestamp(now(), ‘yyyy-mm-dd’) |
+——————————————————–+
| 2021-08-26                                                |
+——————————————————–+
SELECT FROM_TIMESTAMP(NOW(),’yyyy/mm/dd’);
+———————————————————+
| from_timestamp(now(), ‘yyyy/mm/dd’) |
+———————————————————+
| 2021/08/26                                                 |
+———————————————————+
SELECT FROM_TIMESTAMP(NOW(),’MMM dd, yyyy’);
+————————————————————+
| from_timestamp(now(), ‘mmm dd, yyyy’) |
+————————————————————+
| Nov 26, 2021                                                  |
+————————————————————+
SELECT FROM_TIMESTAMP(NOW(),’dd MMM yyyy’);
+———————————————————–+
| from_timestamp(now(), ‘dd mmm yyyy’) |
+———————————————————–+
| 26 Nov 2021                                                  |
+———————————————————–+
SELECT FROM_TIMESTAMP(NOW(),’MMM dd, yyyy HH:mm:ss.SSS’);
+——————————————————————————–+
| from_timestamp(now(), ‘mmm dd, yyyy hh:mm:ss.sss’) |
+——————————————————————————–+
| Nov 26, 2021 07:12:05.785                                                   |
+——————————————————————————–+

This slideshow requires JavaScript.

2 comments

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s