pg.ddx.io pgsql-sql@postgresql.org mailing list archive
help / color / mirror / Atom feedmerging date and time
4+ messages / 4 participants
[nested] [flat]
* merging date and time
@ 1999-03-31 08:44 Marco.Iannacone@DEU.dupont.com
0 siblings, 0 replies; 4+ messages in thread
From: Marco.Iannacone@DEU.dupont.com @ 1999-03-31 08:44 UTC (permalink / raw)
To: pgsql-sql
Hi,
I'm experiencing some problems to create a view in which I put together a
date and a time in the same field...
I have a table which contain a date field (with a date inside) and a
varchar field with time inside..
This is the content of those two field in one record:
|22-03-1999|14:45:27
I just wanted to create a view in which those two field are merged in a
datetime filed..
I tried using different approach but I'm always getting an error message or
while creating the view or when selectin from the created view..
examples:
create view glob_time as select datetime(euigw.day||euigw.time) as tempo
from euigw;
gives me the following error message;
ERROR: There is more than one possible operator '||' for types 'date'
and 'varc
har'
You will have to retype this query using an explicit cast
create view glob_time as select datetime(text(euigw.day)||euigw.time) as
tempo from euigw;
works file, but then if I do select * from glob_time; I get:
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?
thanks,
Marco
^ permalink raw reply [nested|flat] 4+ messages in thread
* merging date and time
@ 1999-03-31 14:03 miannaco@csc.com
1999-03-31 16:01 ` Re: [SQL] merging date and time Ross J. Reedstrom <reedstrm@rice.edu>
0 siblings, 1 reply; 4+ messages in thread
From: miannaco@csc.com @ 1999-03-31 14:03 UTC (permalink / raw)
To: pgsql-sql
Hi,
I'm experiencing some problems to create a view in which I put together a
date and a time in the same field...
I have a table which contain a date field (with a date inside) and a
varchar field with time inside..
This is the content of those two field in one record:
|22-03-1999|14:45:27
I just wanted to create a view in which those two field are merged in a
datetime filed..
I tried using different approach but I'm always getting an error message or
while creating the view or when selectin from the created view..
examples:
create view glob_time as select datetime(euigw.day||euigw.time) as tempo
from euigw;
gives me the following error message;
ERROR: There is more than one possible operator '||' for types 'date'
and 'varc
har'
You will have to retype this query using an explicit cast
create view glob_time as select datetime(text(euigw.day)||euigw.time) as
tempo from euigw;
works file, but then if I do select * from glob_time; I get:
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?
thanks,
Marco
^ permalink raw reply [nested|flat] 4+ messages in thread
* Re: [SQL] merging date and time
1999-03-31 14:03 merging date and time miannaco@csc.com
@ 1999-03-31 16:01 ` Ross J. Reedstrom <reedstrm@rice.edu>
1999-03-31 16:16 ` Re: [SQL] merging date and time Oliver Smith <oliver@kfs.org>
0 siblings, 1 reply; 4+ messages in thread
From: Ross J. Reedstrom @ 1999-03-31 16:01 UTC (permalink / raw)
To: pgsql-sql
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
^ permalink raw reply [nested|flat] 4+ messages in thread
* Re: [SQL] merging date and time
1999-03-31 14:03 merging date and time miannaco@csc.com
1999-03-31 16:01 ` Re: [SQL] merging date and time Ross J. Reedstrom <reedstrm@rice.edu>
@ 1999-03-31 16:16 ` Oliver Smith <oliver@kfs.org>
0 siblings, 0 replies; 4+ messages in thread
From: Oliver Smith @ 1999-03-31 16:16 UTC (permalink / raw)
To: pgsql-sql
On Wed, Mar 31, 1999 at 10:01:20AM -0600, Ross J. Reedstrom wrote:
> 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=>
Or more simply...
select ('22-03-1999'::date + '14:45:27'::timespan) as myDateTime;
mydatetime
----------------------------
Mon Mar 22 14:45:27 1999 GMT
(1 row)
--
If at first you don't succeed, skydiving is not for you...
^ permalink raw reply [nested|flat] 4+ messages in thread
end of thread, other threads:[~1999-03-31 16:16 UTC | newest]
Thread overview: 4+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
1999-03-31 08:44 merging date and time Marco.Iannacone@DEU.dupont.com
1999-03-31 14:03 merging date and time miannaco@csc.com
1999-03-31 16:01 ` Ross J. Reedstrom <reedstrm@rice.edu>
1999-03-31 16:16 ` Oliver Smith <oliver@kfs.org>
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