Devopam is right, your date format looks wrong (should be yyyy-mm-dd rather
than yyyy/mm/dd.
Casting should work, trying this with Hive trunk:
hive> select c1, date_add('1985-01-01', c1) from short1;
FAILED: SemanticException [Error 10014]: Line 1:11 Wrong arguments 'c1':
DATE_ADD() only takes INT types as second argument, got SHORT
hive> select c1, date_add('1985-01-01', cast(c1 as int)) from short1;
OK
484 1986-04-30
98 1985-04-09
278 1985-10-06
255 1985-09-13
409 1986-02-14
165 1985-06-15
27 1985-01-28
311 1985-11-08
86 1985-03-28
238 1985-08-27
Time taken: 0.044 seconds, Fetched: 10 row(s)
But the UDF is a bit restrictive here, we could definitely make
date_add()/date_sub() accept tinyint/smallint/bigint here. I've created
https://issues.apache.org/jira/browse/HIVE-9396 for this.
On Jan 16, 2015, at 1:09 AM, Devopam Mittra <[email protected]> wrote:
> hi Yashwanth,
> Can you please check once if DATE_ADD('1985-01-01', day_key) works for you
>
> regards
> Devopam
>
>
> On Fri, Jan 16, 2015 at 1:12 PM, Yashwanth M <[email protected]> wrote:
> Hi,
>
>
>
> I’ve been facing some issues in using date_add()
>
>
>
> I have column ‘day_key’ that is short integer and stores day keys with
> respect to 1985/01/01.
>
>
>
> I need to extract actual date from this column.
>
>
>
> Date_add(‘1985/01/01’,day_key)
>
> However I get an error saying the second argument needs integer.
>
>
>
> I also did
>
> Date_add(‘1985/01/01’,cast(day_key as int))
>
> Resulted in an error saying the column is short.
>
>
>
> Please help me with this.
>
>
>
> Thanks
>
> Regards,
>
> Yashwanth M | +91 8884 177 884 |www.mu-sigma.com |
>
>
>
> Disclaimer: http://www.mu-sigma.com/disclaimer.html
>
>
>
> --
> Devopam Mittra
> Life and Relations are not binary
--
CONFIDENTIALITY NOTICE
NOTICE: This message is intended for the use of the individual or entity to
which it is addressed and may contain information that is confidential,
privileged and exempt from disclosure under applicable law. If the reader
of this message is not the intended recipient, you are hereby notified that
any printing, copying, dissemination, distribution, disclosure or
forwarding of this communication is strictly prohibited. If you have
received this communication in error, please contact the sender immediately
and delete it from your system. Thank You.