drill-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Andries Engelbrecht <aengelbre...@maprtech.com>
Subject Re: Date Formatting Question
Date Thu, 08 Sep 2016 22:16:10 GMT
Looks like Jason just beat me to it :-)



> On Sep 8, 2016, at 3:15 PM, Andries Engelbrecht <aengelbrecht@maprtech.com> wrote:
> 
> You are likely looking for the to_char function to convert date to a different string
format. You can always convert back to a date by using to_date.
> 
> select current_date, to_char(current_date,'mm/dd/yyyy') from (values(1));
> +---------------+-------------+
> | current_date  |   EXPR$1    |
> +---------------+-------------+
> | 2016-09-08    | 00/08/2016  |
> +---------------+-------------+
> 1 row selected (0.376 seconds)
> 
> See conversion functions here
> 
> http://drill.apache.org/docs/data-type-conversion/#to_char <http://drill.apache.org/docs/data-type-conversion/#to_char>
> 
> 
> --Andries
> 
> 
> 
> 
>> On Sep 8, 2016, at 3:10 PM, Kunal Khatua <kkhatua@maprtech.com <mailto:kkhatua@maprtech.com>>
wrote:
>> 
>> Hi Charles,
>> 
>> There isn't a single function that would convert to the format you want, since that
would be a user-specific format and not native to the internal Drill representation of the
date format. 
>> 
>> Treating the output format of 'mm/dd/yyyy' as a string is a solution, using the date-time
functions that was shared in the link by tokenizing and concatenating the date tokens of month,date
and year.
>> 
>> ~ Kunal
>> On Thu 8-Sep-2016 12:20:43 PM, Charles Givre <cgivre@gmail.com <mailto:cgivre@gmail.com>>
wrote:
>> Hi Khurram,
>> I looked through all that already and I didn't see anything that did what I
>> was wanting to do, or am I missing it?
>> Thanks,
>> -- C
>> 
>> On Thu, Sep 8, 2016 at 3:14 PM, Khurram Faraaz wrote:
>> 
>>> Here is the link to currently supported datetime functions in Drill
>>> 
>>> https://drill.apache.org/docs/date-time-functions-and-arithmetic/#extract <https://drill.apache.org/docs/date-time-functions-and-arithmetic/#extract>
>>> 
>>> On Fri, Sep 9, 2016 at 12:32 AM, Charles Givre wrote:
>>> 
>>>> Hello everyone,
>>>> I have a question about formatting dates. Let's say that I have some
>>> data
>>>> which has dates in format of yyyy-mm-dd but I would like to convert them
>>> to
>>>> mm/dd/yyyy format (or whatever). Does Drill have something that is
>>> roughly
>>>> equivalent to MySQL's DATE_FORMAT( , ) function
>>>> whereby you can change the formatting of a date to whatever you want?
>>>> Thanks,
>>>> -- Charles
>>>> 
>>> 
> 


Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message