Return-Path: X-Original-To: apmail-hive-dev-archive@www.apache.org Delivered-To: apmail-hive-dev-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 06D6A177EE for ; Wed, 1 Apr 2015 06:30:10 +0000 (UTC) Received: (qmail 77179 invoked by uid 500); 1 Apr 2015 06:30:09 -0000 Delivered-To: apmail-hive-dev-archive@hive.apache.org Received: (qmail 77107 invoked by uid 500); 1 Apr 2015 06:30:09 -0000 Mailing-List: contact dev-help@hive.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@hive.apache.org Delivered-To: mailing list dev@hive.apache.org Received: (qmail 77085 invoked by uid 99); 1 Apr 2015 06:30:09 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 01 Apr 2015 06:30:09 +0000 X-ASF-Spam-Status: No, hits=1.5 required=5.0 tests=HTML_MESSAGE,RCVD_IN_DNSWL_LOW,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of apivovarov@gmail.com designates 209.85.217.175 as permitted sender) Received: from [209.85.217.175] (HELO mail-lb0-f175.google.com) (209.85.217.175) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 01 Apr 2015 06:29:43 +0000 Received: by lbdc10 with SMTP id c10so28677031lbd.2 for ; Tue, 31 Mar 2015 23:28:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :content-type; bh=4SyV9EPspY5/WVbyiEBac0cO5UlEeatt9TA3m7ofoT4=; b=xuFdBBsOuEaPW4xR4SdVY6YopO0ip/MqdCBEjPckgI/KrYDp8H3ZxOguWPs11t1oz+ qoRacmBA6jsV2M0WdXS9Ds3d0bkJkw+ff7vqTlxI1HWk3J7G3XcKmhBx8YoOwAUygH49 ktyN2iz2j4sDi2rfHegNRtamRqeUIAde8Ua9JEE356lAt2mbGBBgKflm60DLRa726Nzd QzA1yUZibBJ/uxoWJg55aR5SxeKjmDJ7AMBr8BqR7sa11yGO93ByPNMnqw869Rc/U/nG tMKZlFAumhFNQ3UcVhkH8s2kYQ7rjVJiA50/REYauPG+EoLKgstF65IIPFpC/7cLTtrE mG/w== X-Received: by 10.152.163.35 with SMTP id yf3mr7663941lab.86.1427869691887; Tue, 31 Mar 2015 23:28:11 -0700 (PDT) MIME-Version: 1.0 Received: by 10.25.151.79 with HTTP; Tue, 31 Mar 2015 23:27:51 -0700 (PDT) In-Reply-To: References: From: Alexander Pivovarov Date: Tue, 31 Mar 2015 23:27:51 -0700 Message-ID: Subject: Re: TIMESTAMP to DATE conversion for negative unix time To: "dev@hive.apache.org" Content-Type: multipart/alternative; boundary=001a11340b14c546550512a3d19f X-Virus-Checked: Checked by ClamAV on apache.org --001a11340b14c546550512a3d19f Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable correction for the first example select cast(cast('1966-01-01 00:00:01' as timestamp) as date); 1966-01-02 On Tue, Mar 31, 2015 at 11:26 PM, Alexander Pivovarov wrote: > Hi Everyone > > I noticed interesting behaviour for timestamp to date hive type conversio= n > for negative unix time. > > For example: > > select cast(cast('1966-01-01 00:00:01' as timestamp) as date); > 1966-02-02 > > Should it work this way? > > Another example > select last_day(cast('1966-01-31 00:00:01' as timestamp)); > OK > 1966-02-28 > > > more details: > Date: 1966-01-01 00:00:01 > unix time UTC: -126230399 > > daysSinceEpoch=3D=E2=88=92126230399000 / 86400000 =3D -1460.999988 > int daysSinceEpoch =3D -1460 > DateWritable having daysSinceEpoch=3D-1460 is 1966-01-02 > > > > > > --001a11340b14c546550512a3d19f--