Return-Path: X-Original-To: apmail-db-derby-dev-archive@www.apache.org Delivered-To: apmail-db-derby-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 7FF1310C7C for ; Wed, 26 Feb 2014 22:08:27 +0000 (UTC) Received: (qmail 88036 invoked by uid 500); 26 Feb 2014 22:08:25 -0000 Delivered-To: apmail-db-derby-dev-archive@db.apache.org Received: (qmail 87962 invoked by uid 500); 26 Feb 2014 22:08:25 -0000 Mailing-List: contact derby-dev-help@db.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: Delivered-To: mailing list derby-dev@db.apache.org Received: (qmail 87829 invoked by uid 99); 26 Feb 2014 22:08:23 -0000 Received: from arcas.apache.org (HELO arcas.apache.org) (140.211.11.28) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 26 Feb 2014 22:08:23 +0000 Date: Wed, 26 Feb 2014 22:08:23 +0000 (UTC) From: "Myrna van Lunteren (JIRA)" To: derby-dev@db.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Commented] (DERBY-896) Cast date to timestamp results in "ERROR 42846: Cannot convert types 'DATE' to 'TIMESTAMP'." MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 [ https://issues.apache.org/jira/browse/DERBY-896?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13913587#comment-13913587 ] Myrna van Lunteren commented on DERBY-896: ------------------------------------------ It appears from the previous discussion that this is something that should've been allowed as per the SQL Standard, so I'd think it a good one to backport, at least to 10.10... > Cast date to timestamp results in "ERROR 42846: Cannot convert types 'DATE' to 'TIMESTAMP'." > -------------------------------------------------------------------------------------------- > > Key: DERBY-896 > URL: https://issues.apache.org/jira/browse/DERBY-896 > Project: Derby > Issue Type: Bug > Components: SQL > Affects Versions: 10.1.2.1 > Environment: --------- Derby Information -------- > JRE - JDBC: J2SE 1.4.2 - JDBC 3.0 > [D:\Programme\Derby\bin\lib\derby.jar] 10.1.2.1 - (330608) > [D:\Programme\Derby\bin\lib\derbytools.jar] 10.1.2.1 - (330608) > Reporter: Oleksandr Alesinskyy > Assignee: Knut Anders Hatlen > Labels: derby_backport_reject_10_10, derby_triage10_5_2 > Fix For: 10.11.0.0 > > Attachments: allow-casts-with-tests.diff, allow-casts.diff, w.sql > > > Cast date to timestamp results in "ERROR 42846: Cannot convert types 'DATE' to 'TIMESTAMP'.", > e.g. in ij: > select cast(cast ('2006-01-01' as date) as timestamp) from sys.sysschemas; > or > select cast (current_date as timestamp) from bradi_dat.lpaip01; > The similar issue exists for time ("ERROR 42846: Cannot convert types 'TIME' to 'TIMESTAMP'.", > Documentation clearly states that these conversions are allowed, see table 1 in a description of CAST function in the Derby Reference Manual and comment about "Conversion of date/time values" below that table (see below as well). > Conversions of date/time values > A date/time value can always be converted to and from a TIMESTAMP. If a DATE is > converted to a TIMESTAMP, the TIME component of the resulting TIMESTAMP is always > 00:00:00. If a TIME data value is converted to a TIMESTAMP, the DATE component is > set to the value of CURRENT_DATE at the time the CAST is executed. If a TIMESTAMP > is converted to a DATE, the TIME component is silently truncated. If a TIMESTAMP is > converted to a TIME, the DATE component is silently truncated. > -- This message was sent by Atlassian JIRA (v6.1.5#6160)