Thread: Datetime field

Datetime field

From
HenrikP@mail.ikasths.dk (Henrik Denseje Pedersen)
Date:
Hi all...


In a database i have created a datetime field.. its works fine, but is
there someway i can get the result back in "normal" date format
instead of this "Wed Aug 19 00:00:00 1998 MET DST".

I need to use it in my program, so i need it in the normal datetime format:
wich is : 08-19-98 00:00:00

By the way, im programming in Perl, so if anyone know a funktion to
convert it back, that could be helpfull too


Yours Sincerely

Henrik Pedersen
--

Re: [SQL] Datetime field

From
"Jose' Soares"
Date:
1. If you define it as TIMESTAMP instead of DATETIME you have the format
   as you desire.

2. If you set DateStyle TO 'ISO', you may have the same result. Take a
look:


prova=> create table tbl ("Time Stamp"  timestamp, "Date Time"
datetime);
CREATE
prova=> insert into tbl values (current_timestamp, 'now');
INSERT 82754 1

prova=> \x
turned on expanded table representation

prova=> set datestyle to 'POSTGRES';
SET VARIABLE
prova=> select * from tbl;
Field     | Value
-- RECORD 0 --
Time Stamp| 1998-09-17 17:19:48+02
Date Time | Thu 17 Sep 17:19:48 1998 CEST
(1 row)

prova=> set datestyle to 'ISO';
SET VARIABLE
prova=> select * from tbl;
Field     | Value
-- RECORD 0 --
Time Stamp| 1998-09-17 17:19:48+02
Date Time | 1998-09-17 17:19:48+02
(1 row)


I hope this help you
      Jose'



Henrik Denseje Pedersen wrote:
>
> Hi all...
>
> In a database i have created a datetime field.. its works fine, but is
> there someway i can get the result back in "normal" date format
> instead of this "Wed Aug 19 00:00:00 1998 MET DST".
>
> I need to use it in my program, so i need it in the normal datetime format:
> wich is : 08-19-98 00:00:00
>
> By the way, im programming in Perl, so if anyone know a funktion to
> convert it back, that could be helpfull too
>
> Yours Sincerely
>
> Henrik Pedersen
> --