Re: time format

Lists: pgsql-hackers
From: ivan <iv(at)psycho(dot)pl>
To: pgsql-hackers(at)postgreSQL(dot)org
Subject: time format
Date: 2004-01-01 15:55:18
Message-ID: Pine.LNX.4.56.0401011653090.13912@rex.anfa.pl
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

how can i change default time format because now i have for example
2004-01-01 16:51:46.995927 but i want only 2004-01-01 16:51:46, with out
millisec. a tryed with Data-Style but there arent custom style :/


From: Christopher Kings-Lynne <chriskl(at)familyhealth(dot)com(dot)au>
To: ivan <iv(at)psycho(dot)pl>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: time format
Date: 2004-01-02 04:56:33
Message-ID: 3FF4FA01.9070402@familyhealth.com.au
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Create table with type TIMESTAMP(0)

Chris

ivan wrote:

>
> how can i change default time format because now i have for example
> 2004-01-01 16:51:46.995927 but i want only 2004-01-01 16:51:46, with out
> millisec. a tryed with Data-Style but there arent custom style :/
>
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 6: Have you searched our list archives?
>
> http://archives.postgresql.org


From: ivan <iv(at)psycho(dot)pl>
To: Christopher Kings-Lynne <chriskl(at)familyhealth(dot)com(dot)au>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: time format
Date: 2004-01-03 08:25:14
Message-ID: Pine.LNX.4.56.0401030919210.28459@rex.anfa.pl
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers


but what about default style ?
first time when i saw DateStyle i thought that i can use it like C/C++
function strftime. I would be not bad idea to have custom data style :)

On Fri, 2 Jan 2004, Christopher Kings-Lynne wrote:

> Create table with type TIMESTAMP(0)
>
> Chris
>
> ivan wrote:
>
> >
> > how can i change default time format because now i have for example
> > 2004-01-01 16:51:46.995927 but i want only 2004-01-01 16:51:46, with out
> > millisec. a tryed with Data-Style but there arent custom style :/
> >
> >
> >
> > ---------------------------(end of broadcast)---------------------------
> > TIP 6: Have you searched our list archives?
> >
> > http://archives.postgresql.org
>
> ---------------------------(end of broadcast)---------------------------
> TIP 1: subscribe and unsubscribe commands go to majordomo(at)postgresql(dot)org
>


From: Kurt Roeckx <Q(at)ping(dot)be>
To: ivan <iv(at)psycho(dot)pl>
Cc: Christopher Kings-Lynne <chriskl(at)familyhealth(dot)com(dot)au>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: time format
Date: 2004-01-03 11:19:06
Message-ID: 20040103111906.GA12243@ping.be
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On Sat, Jan 03, 2004 at 09:25:14AM +0100, ivan wrote:
>
> but what about default style ?
> first time when i saw DateStyle i thought that i can use it like C/C++
> function strftime. I would be not bad idea to have custom data style :)

Use to_char() function to put it in any format you want.

Kurt


From: ivan <iv(at)psycho(dot)pl>
To: Kurt Roeckx <Q(at)ping(dot)be>
Cc: Christopher Kings-Lynne <chriskl(at)familyhealth(dot)com(dot)au>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: time format
Date: 2004-01-03 21:20:57
Message-ID: Pine.LNX.4.56.0401032218430.16575@rex.anfa.pl
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers


ok, bat each time where i want to do select .. a nie tu use to_char,
but it should be in function timestamp_out to convert time to string
it would be easer and faster.

On Sat, 3 Jan 2004, Kurt Roeckx wrote:

> On Sat, Jan 03, 2004 at 09:25:14AM +0100, ivan wrote:
> >
> > but what about default style ?
> > first time when i saw DateStyle i thought that i can use it like C/C++
> > function strftime. I would be not bad idea to have custom data style :)
>
> Use to_char() function to put it in any format you want.
>
>
> Kurt
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 8: explain analyze is your friend
>


From: Martin Marques <martin(at)bugs(dot)unl(dot)edu(dot)ar>
To: ivan <iv(at)psycho(dot)pl>, Kurt Roeckx <Q(at)ping(dot)be>
Cc: Christopher Kings-Lynne <chriskl(at)familyhealth(dot)com(dot)au>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: time format
Date: 2004-01-04 12:54:25
Message-ID: 200401040954.25708.martin@bugs.unl.edu.ar
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

El Sáb 03 Ene 2004 18:20, ivan escribió:
> ok, bat each time where i want to do select .. a nie tu use to_char,
> but it should be in function timestamp_out to convert time to string
> it would be easer and faster.

Look deeper into what Christopher said and use casting to get the right
output:

prueba=> select now();
now
-------------------------------
2004-01-04 09:53:41.131079-03
(1 row)

prueba=> select now()::timestamp(0);
now
---------------------
2004-01-04 09:53:43
(1 row)

Get the difference?

--
09:52:01 up 39 days, 16:08, 2 users, load average: 0.60, 0.71, 0.72
-----------------------------------------------------------------
Martín Marqués | select 'mmarques' || '@' || 'unl.edu.ar'
Centro de Telematica | DBA, Programador, Administrador
Universidad Nacional
del Litoral
-----------------------------------------------------------------


From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Martin Marques <martin(at)bugs(dot)unl(dot)edu(dot)ar>
Cc: ivan <iv(at)psycho(dot)pl>, Kurt Roeckx <Q(at)ping(dot)be>, Christopher Kings-Lynne <chriskl(at)familyhealth(dot)com(dot)au>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: time format
Date: 2004-01-04 17:33:01
Message-ID: 21057.1073237581@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Martin Marques <martin(at)bugs(dot)unl(dot)edu(dot)ar> writes:
> Look deeper into what Christopher said and use casting to get the right
> output:
> prueba=> select now()::timestamp(0);

There's also "current_timestamp(0)", which is a more standards-compliant
way of doing the same thing.

regards, tom lane


From: ivan <iv(at)psycho(dot)pl>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Martin Marques <martin(at)bugs(dot)unl(dot)edu(dot)ar>, Kurt Roeckx <Q(at)ping(dot)be>, Christopher Kings-Lynne <chriskl(at)familyhealth(dot)com(dot)au>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: time format
Date: 2004-01-04 21:22:52
Message-ID: Pine.LNX.4.56.0401042220480.13578@rex.anfa.pl
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers


i know, but i talking about default time output, it would be for
time, date and date with time, not formating all the time.

On Sun, 4 Jan 2004, Tom Lane wrote:

> Martin Marques <martin(at)bugs(dot)unl(dot)edu(dot)ar> writes:
> > Look deeper into what Christopher said and use casting to get the right
> > output:
> > prueba=> select now()::timestamp(0);
>
> There's also "current_timestamp(0)", which is a more standards-compliant
> way of doing the same thing.
>
> regards, tom lane
>


From: Martin Marques <martin(at)bugs(dot)unl(dot)edu(dot)ar>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: ivan <iv(at)psycho(dot)pl>, Kurt Roeckx <Q(at)ping(dot)be>, Christopher Kings-Lynne <chriskl(at)familyhealth(dot)com(dot)au>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: time format
Date: 2004-01-05 03:50:02
Message-ID: 1073274602.3ff8deeaeeeb5@bugs.unl.edu.ar
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Quoting Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>:

> Martin Marques <martin(at)bugs(dot)unl(dot)edu(dot)ar> writes:
> > Look deeper into what Christopher said and use casting to get the right
> > output:
> > prueba=> select now()::timestamp(0);
>
> There's also "current_timestamp(0)", which is a more standards-compliant
> way of doing the same thing.

Didn´t know that existed. :-)

Anyway, my observation was not on the now() function, but at the casting. He
wants the output of th select over a timestamp field to come out without the
milliseconds, which is done with the casting.

Now, seeing your mail I realize that what he may want is this:

CREATE TABLE table_name (
.....
time_field timestamp(0)
);

Remember you will lose those milliseconds for ever with this table definition.

--
Porqué usar una base de datos relacional cualquiera,
si podés usar PostgreSQL?
-----------------------------------------------------------------
Martín Marqués | mmarques(at)unl(dot)edu(dot)ar
Programador, Administrador, DBA | Centro de Telematica
Universidad Nacional
del Litoral
-----------------------------------------------------------------


From: Karel Zak <zakkr(at)zf(dot)jcu(dot)cz>
To: ivan <iv(at)psycho(dot)pl>
Cc: Kurt Roeckx <Q(at)ping(dot)be>, Christopher Kings-Lynne <chriskl(at)familyhealth(dot)com(dot)au>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: time format
Date: 2004-01-05 09:36:05
Message-ID: 20040105093605.GE13231@zf.jcu.cz
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On Sat, Jan 03, 2004 at 10:20:57PM +0100, ivan wrote:
>
> ok, bat each time where i want to do select .. a nie tu use to_char,
> but it should be in function timestamp_out to convert time to string
> it would be easer and faster.

I don't think it will too much faster :-)

BTW, for example the Oracle allows to define default date/time output
format by same way as for to_char().

TODO (?):

SET TIMESTAMP_FORMAT = 'MM/DD/YYYY HH24:MI:SS';

SELECT 'now'::timestamp;
timestamp
----------------------------
01/05/2004 10:25:01

But it require check (be sure) that defined format is possible without
problems convert back from string to timestamp. For this Thomas didn't
like this idea.

I think dynamic timestamp format is final solution of all problems with
PostgreSQL date/time formats.

Comments?

Karel

>
> On Sat, 3 Jan 2004, Kurt Roeckx wrote:
>
> > On Sat, Jan 03, 2004 at 09:25:14AM +0100, ivan wrote:
> > >
> > > but what about default style ?
> > > first time when i saw DateStyle i thought that i can use it like C/C++
> > > function strftime. I would be not bad idea to have custom data style :)
> >
> > Use to_char() function to put it in any format you want.
> >
> >
> > Kurt
> >
> >
> > ---------------------------(end of broadcast)---------------------------
> > TIP 8: explain analyze is your friend
> >
>
> ---------------------------(end of broadcast)---------------------------
> TIP 9: the planner will ignore your desire to choose an index scan if your
> joining column's datatypes do not match

--
Karel Zak <zakkr(at)zf(dot)jcu(dot)cz>
http://home.zf.jcu.cz/~zakkr/


From: ivan <iv(at)psycho(dot)pl>
To: Karel Zak <zakkr(at)zf(dot)jcu(dot)cz>
Cc: Kurt Roeckx <Q(at)ping(dot)be>, Christopher Kings-Lynne <chriskl(at)familyhealth(dot)com(dot)au>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: time format
Date: 2004-01-05 20:42:31
Message-ID: Pine.LNX.4.56.0401052130480.5956@rex.anfa.pl
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers


there can be same problems with back convering, but its would be only
when select is going out, to cstring form, and all its depend on user,
but this is ok :)

On Mon, 5 Jan 2004, Karel Zak wrote:

> On Sat, Jan 03, 2004 at 10:20:57PM +0100, ivan wrote:
> >
> > ok, bat each time where i want to do select .. a nie tu use to_char,
> > but it should be in function timestamp_out to convert time to string
> > it would be easer and faster.
>
> I don't think it will too much faster :-)
>
> BTW, for example the Oracle allows to define default date/time output
> format by same way as for to_char().
>
> TODO (?):
>
> SET TIMESTAMP_FORMAT = 'MM/DD/YYYY HH24:MI:SS';
>
> SELECT 'now'::timestamp;
> timestamp
> ----------------------------
> 01/05/2004 10:25:01
>
>
> But it require check (be sure) that defined format is possible without
> problems convert back from string to timestamp. For this Thomas didn't
> like this idea.
>
> I think dynamic timestamp format is final solution of all problems with
> PostgreSQL date/time formats.
>
> Comments?
>
> Karel
>
> >
> > On Sat, 3 Jan 2004, Kurt Roeckx wrote:
> >
> > > On Sat, Jan 03, 2004 at 09:25:14AM +0100, ivan wrote:
> > > >
> > > > but what about default style ?
> > > > first time when i saw DateStyle i thought that i can use it like C/C++
> > > > function strftime. I would be not bad idea to have custom data style :)
> > >
> > > Use to_char() function to put it in any format you want.
> > >
> > >
> > > Kurt
> > >
> > >
> > > ---------------------------(end of broadcast)---------------------------
> > > TIP 8: explain analyze is your friend
> > >
> >
> > ---------------------------(end of broadcast)---------------------------
> > TIP 9: the planner will ignore your desire to choose an index scan if your
> > joining column's datatypes do not match
>
> --
> Karel Zak <zakkr(at)zf(dot)jcu(dot)cz>
> http://home.zf.jcu.cz/~zakkr/
>