You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@hive.apache.org by yogesh dhari <yo...@gmail.com> on 2013/12/24 07:54:14 UTC

Date format in Hive

Hello All,

I have a hive table in which dates are stored in string format.

like

2013-01-01
2013-02-01
2013-03-01


I have a use case where I need this date like
20130101
20130201
20130301

and want to multiply each with 100
like

2013010100
2013020100
2013030100


How can I do it into Hive

pls help.

Thanks & Regards
Yogesh

Re: Date format in Hive

Posted by Nitin Pawar <ni...@gmail.com>.
easiest way would be something like this  cast ((regexp_replace(column,
'-', '') as int)*100

then you can do datetime conversion and end up doing same magic other way


On Tue, Dec 24, 2013 at 12:24 PM, yogesh dhari <yo...@gmail.com> wrote:

> Hello All,
>
> I have a hive table in which dates are stored in string format.
>
> like
>
> 2013-01-01
> 2013-02-01
> 2013-03-01
>
>
> I have a use case where I need this date like
> 20130101
> 20130201
> 20130301
>
> and want to multiply each with 100
> like
>
> 2013010100
> 2013020100
> 2013030100
>
>
> How can I do it into Hive
>
> pls help.
>
> Thanks & Regards
> Yogesh
>



-- 
Nitin Pawar

Re: Date format in Hive

Posted by Sreenath <sr...@gmail.com>.
you can use python rather than java. its simpler to learn and easier to
write


On Tue, Dec 24, 2013 at 2:08 PM, yogesh dhari <yo...@gmail.com> wrote:

> Java nahi aati, to udf kaha se likhu..
>
> koi hive ka function hi bata ya work around it..
>
> ya fir shell script me kaisey kerney ka h ...
>
>
> On Tue, Dec 24, 2013 at 12:47 PM, <as...@wipro.com> wrote:
>
>> Hello Dhari,
>>
>> Write a hive udf,
>> 1.which ll take date as argument.
>> 2.extract yr, mon,date from string, create a new string combining them
>> 3. convert it to numeric and multiply 100..
>> 4. return this value from udf.
>>
>> Thanks,
>> Ashok
>> ________________________________________
>> From: yogesh dhari [yogeshhive@gmail.com]
>> Sent: Tuesday, December 24, 2013 12:24 PM
>> To: user@hive.apache.org
>> Subject: Date format in Hive
>>
>> Hello All,
>>
>> I have a hive table in which dates are stored in string format.
>>
>> like
>>
>> 2013-01-01
>> 2013-02-01
>> 2013-03-01
>>
>>
>> I have a use case where I need this date like
>> 20130101
>> 20130201
>> 20130301
>>
>> and want to multiply each with 100
>> like
>>
>> 2013010100
>> 2013020100
>> 2013030100
>>
>>
>> How can I do it into Hive
>>
>> pls help.
>>
>> Thanks & Regards
>> Yogesh
>>
>> The information contained in this electronic message and any attachments
>> to this message are intended for the exclusive use of the addressee(s) and
>> may contain proprietary, confidential or privileged information. If you are
>> not the intended recipient, you should not disseminate, distribute or copy
>> this e-mail. Please notify the sender immediately and destroy all copies of
>> this message and any attachments.
>>
>> WARNING: Computer viruses can be transmitted via email. The recipient
>> should check this email and any attachments for the presence of viruses.
>> The company accepts no liability for any damage caused by any virus
>> transmitted by this email.
>>
>> www.wipro.com
>>
>
>


-- 
Sreenath S Kamath
Bangalore
Ph No:+91-9590989106

Re: Date format in Hive

Posted by yogesh dhari <yo...@gmail.com>.
Java nahi aati, to udf kaha se likhu..

koi hive ka function hi bata ya work around it..

ya fir shell script me kaisey kerney ka h ...


On Tue, Dec 24, 2013 at 12:47 PM, <as...@wipro.com> wrote:

> Hello Dhari,
>
> Write a hive udf,
> 1.which ll take date as argument.
> 2.extract yr, mon,date from string, create a new string combining them
> 3. convert it to numeric and multiply 100..
> 4. return this value from udf.
>
> Thanks,
> Ashok
> ________________________________________
> From: yogesh dhari [yogeshhive@gmail.com]
> Sent: Tuesday, December 24, 2013 12:24 PM
> To: user@hive.apache.org
> Subject: Date format in Hive
>
> Hello All,
>
> I have a hive table in which dates are stored in string format.
>
> like
>
> 2013-01-01
> 2013-02-01
> 2013-03-01
>
>
> I have a use case where I need this date like
> 20130101
> 20130201
> 20130301
>
> and want to multiply each with 100
> like
>
> 2013010100
> 2013020100
> 2013030100
>
>
> How can I do it into Hive
>
> pls help.
>
> Thanks & Regards
> Yogesh
>
> The information contained in this electronic message and any attachments
> to this message are intended for the exclusive use of the addressee(s) and
> may contain proprietary, confidential or privileged information. If you are
> not the intended recipient, you should not disseminate, distribute or copy
> this e-mail. Please notify the sender immediately and destroy all copies of
> this message and any attachments.
>
> WARNING: Computer viruses can be transmitted via email. The recipient
> should check this email and any attachments for the presence of viruses.
> The company accepts no liability for any damage caused by any virus
> transmitted by this email.
>
> www.wipro.com
>

RE: Date format in Hive

Posted by as...@wipro.com.
Hello Dhari,

Write a hive udf, 
1.which ll take date as argument.
2.extract yr, mon,date from string, create a new string combining them
3. convert it to numeric and multiply 100..
4. return this value from udf.

Thanks,
Ashok
________________________________________
From: yogesh dhari [yogeshhive@gmail.com]
Sent: Tuesday, December 24, 2013 12:24 PM
To: user@hive.apache.org
Subject: Date format in Hive

Hello All,

I have a hive table in which dates are stored in string format.

like

2013-01-01
2013-02-01
2013-03-01


I have a use case where I need this date like
20130101
20130201
20130301

and want to multiply each with 100
like

2013010100
2013020100
2013030100


How can I do it into Hive

pls help.

Thanks & Regards
Yogesh

The information contained in this electronic message and any attachments to this message are intended for the exclusive use of the addressee(s) and may contain proprietary, confidential or privileged information. If you are not the intended recipient, you should not disseminate, distribute or copy this e-mail. Please notify the sender immediately and destroy all copies of this message and any attachments. 

WARNING: Computer viruses can be transmitted via email. The recipient should check this email and any attachments for the presence of viruses. The company accepts no liability for any damage caused by any virus transmitted by this email.

www.wipro.com