You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@drill.apache.org by Paolo Spanevello <pa...@gmail.com> on 2016/02/12 16:15:11 UTC
handling Date
Dear All,
I have a field with a date like this:
Date
2016/01/16 09:44:28 UTC
I would like to split it in Date, Time and remove "UTC".
Somebody can support me?
Best,
Paolo
Re: handling Date
Posted by Abdel Hakim Deneche <ad...@maprtech.com>.
Would EXTRACT help ?
http://drill.apache.org/docs/date-time-functions-and-arithmetic/#extract
On Fri, Feb 12, 2016 at 7:15 AM, Paolo Spanevello <pa...@gmail.com>
wrote:
> Dear All,
>
> I have a field with a date like this:
>
>
> Date
>
> 2016/01/16 09:44:28 UTC
> I would like to split it in Date, Time and remove "UTC".
>
> Somebody can support me?
>
> Best,
> Paolo
>
--
Abdelhakim Deneche
Software Engineer
<http://www.mapr.com/>
Now Available - Free Hadoop On-Demand Training
<http://www.mapr.com/training?utm_source=Email&utm_medium=Signature&utm_campaign=Free%20available>
Re: handling Date
Posted by Paolo Spanevello <pa...@gmail.com>.
thanks it works!
2016-02-12 17:53 GMT+01:00 Andries Engelbrecht <ae...@maprtech.com>:
> You can use to_timestamp to get the timestamp and then just cast the date
> and time from the timestamp.
>
> 0: jdbc:drill:> select CAST(to_timestamp('2016/01/16 09:44:28 UTC',
> 'YYYY/MM/dd HH:mm:ss z') as date) from (values(1));
> +-------------+
> | EXPR$0 |
> +-------------+
> | 2016-01-16 |
> +-------------+
> 1 row selected (0.148 seconds)
> 0: jdbc:drill:> select CAST(to_timestamp('2016/01/16 09:44:28 UTC',
> 'YYYY/MM/dd HH:mm:ss z') as time) from (values(1));
> +-----------+
> | EXPR$0 |
> +-----------+
> | 09:44:28 |
> +-----------+
> 1 row selected (0.15 seconds)
>
> --Andries
>
> > On Feb 12, 2016, at 7:15 AM, Paolo Spanevello <pa...@gmail.com>
> wrote:
> >
> > Dear All,
> >
> > I have a field with a date like this:
> >
> >
> > Date
> >
> > 2016/01/16 09:44:28 UTC
> > I would like to split it in Date, Time and remove "UTC".
> >
> > Somebody can support me?
> >
> > Best,
> > Paolo
>
>
Re: handling Date
Posted by Andries Engelbrecht <ae...@maprtech.com>.
You can use to_timestamp to get the timestamp and then just cast the date and time from the timestamp.
0: jdbc:drill:> select CAST(to_timestamp('2016/01/16 09:44:28 UTC', 'YYYY/MM/dd HH:mm:ss z') as date) from (values(1));
+-------------+
| EXPR$0 |
+-------------+
| 2016-01-16 |
+-------------+
1 row selected (0.148 seconds)
0: jdbc:drill:> select CAST(to_timestamp('2016/01/16 09:44:28 UTC', 'YYYY/MM/dd HH:mm:ss z') as time) from (values(1));
+-----------+
| EXPR$0 |
+-----------+
| 09:44:28 |
+-----------+
1 row selected (0.15 seconds)
--Andries
> On Feb 12, 2016, at 7:15 AM, Paolo Spanevello <pa...@gmail.com> wrote:
>
> Dear All,
>
> I have a field with a date like this:
>
>
> Date
>
> 2016/01/16 09:44:28 UTC
> I would like to split it in Date, Time and remove "UTC".
>
> Somebody can support me?
>
> Best,
> Paolo