pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Ross J. Reedstrom <reedstrm@rice.edu>
To: pgsql-sql@postgresql.org
Subject: Re: [SQL] merging date and time
Date: Wed, 31 Mar 1999 10:01:20 -0600
Message-ID: <370246D0.4F395EE7@rice.edu> (raw)
References: <C1256745.004D28AB.00@csc.com>

miannaco@csc.com wrote:
> 
> Hi,
> I'm experiencing some problems to create a view in which I put together a
> date and a time in the same field...

> 
> ERROR:  Bad datetime external representation 'Mon 22 Mar 00:00:00 1999
> MET14:45:27'
> 
> does anyone have an idea about how to solve this?

Well, the error is exactly what it says - that's not a date time. AS you
can see, the text version of the 'date' type includes a time of
00:00:00. This lead us to a clue - you need to add the time to the date
before the conversion:

test=> create table t1 (d date, t text);
CREATE
test=> insert into t1 values('22-03-1999','14:45:27');
INSERT 101293 1
test=> select datetime(d+timespan(t)) from t1;
datetime                    
----------------------------
Mon Mar 22 14:45:27 1999 CST
(1 row)

test=> drop table t1;
DROP
test=> 


HTH,
Ross

P.S. no need to send your question twice - and it appeared three times!

-- 
Ross J. Reedstrom, Ph.D., <reedstrm@rice.edu> 
NSBRI Research Scientist/Programmer
Computer and Information Technology Institute
Rice University, 6100 S. Main St.,  Houston, TX 77005



view thread (4+ messages)  latest in thread

Message-ID: <370246D0.4F395EE7@rice.edu>
Permalink:  ../370246D0.4F395EE7@rice.edu/
Also on:    postgresql.org/message-id/370246D0.4F395EE7@rice.edu

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-sql@postgresql.org
  Cc: reedstrm@rice.edu
  Subject: Re: [SQL] merging date and time
  In-Reply-To: <370246D0.4F395EE7@rice.edu>
  References: <C1256745.004D28AB.00@csc.com> <370246D0.4F395EE7@rice.edu>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox