pg.ddx.io pgsql-sql@postgresql.org mailing list archive
help / color / mirror / Atom feedfunction year!
2+ messages / 2 participants
[nested] [flat]
* function year!
@ 1998-08-17 08:59 Jerome Knobl <jknobl@mandanet.ch>
1998-08-17 09:28 ` Re: [SQL] function year! Herouth Maoz <herouth@oumail.openu.ac.il>
0 siblings, 1 reply; 2+ messages in thread
From: Jerome Knobl @ 1998-08-17 08:59 UTC (permalink / raw)
To: pgsql-sql
Hello,
I have a timestamp value, and I'm tring to get only the year, the month
or the day.
I'm using the function now() to put some value inside.
I tried the function year(..) (select year(thedate) from mytable;)
but that function are not define! I'm looking for a simple way to get my
informations?
Thank.
Jérôme Knöbl, MandaNEt, Switzerland
^ permalink raw reply [nested|flat] 2+ messages in thread
* Re: [SQL] function year!
1998-08-17 08:59 function year! Jerome Knobl <jknobl@mandanet.ch>
@ 1998-08-17 09:28 ` Herouth Maoz <herouth@oumail.openu.ac.il>
0 siblings, 0 replies; 2+ messages in thread
From: Herouth Maoz @ 1998-08-17 09:28 UTC (permalink / raw)
To: Jerome Knobl <jknobl@mandanet.ch>; pgsql-sql
At 11:59 +0300 on 17/8/98, Jerome Knobl wrote:
> Hello,
>
> I have a timestamp value, and I'm tring to get only the year, the month
> or the day.
> I'm using the function now() to put some value inside.
>
> I tried the function year(..) (select year(thedate) from mytable;)
>
> but that function are not define! I'm looking for a simple way to get my
> informations?
You want the year, the month, and the day.
So, define a separate function for each interesting part? A bit of a waste,
isn't it? There is a function "date_part()", which accepts two arguments -
one is a text saying which part you want, and one is the data itself.
Note that it is defined on the datetime type. So if you want to use
timestamp, you will have to convert it, like:
date_part( 'year', datetime( my_timestamp ) )
As usual, I recommend using the type datetime, not timestamp, in your table.
More information about the date_part() function is in the pgbuiltin man page.
Herouth
--
Herouth Maoz, Internet developer.
Open University of Israel - Telem project
http://telem.openu.ac.il/~herutma
^ permalink raw reply [nested|flat] 2+ messages in thread
end of thread, other threads:[~1998-08-17 09:28 UTC | newest]
Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
1998-08-17 08:59 function year! Jerome Knobl <jknobl@mandanet.ch>
1998-08-17 09:28 ` Herouth Maoz <herouth@oumail.openu.ac.il>
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