From: Herouth Maoz <herouth@oumail.openu.ac.il>
To: Jerome Knobl <jknobl@mandanet.ch>
To: pgsql-sql@postgreSQL.org
Subject: Re: [SQL] function year!
Date: Mon, 17 Aug 1998 12:28:52 +0300
Message-ID: <l03110703b1fda5b259e3@[147.233.159.109]> (raw)
In-Reply-To: <35D7F0FA.4C48F4C9@mandanet.ch>
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
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: herouth@oumail.openu.ac.il, jknobl@mandanet.ch
Subject: Re: [SQL] function year!
In-Reply-To: <l03110703b1fda5b259e3@[147.233.159.109]>
References: <35D7F0FA.4C48F4C9@mandanet.ch> <l03110703b1fda5b259e3@[147.233.159.109]>
* 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