From jaydip@ontrackindia.com Thu Aug 30 14:42:29 2001 Received: from postgresql.org.org (webmail.postgresql.org [216.126.85.28]) by postgresql.org (8.11.3/8.11.4) with SMTP id f7UEgTf41991 for ; Thu, 30 Aug 2001 10:42:29 -0400 (EDT) (envelope-from pgsql-sql-owner@postgresql.org) Received: from mail3.registeredsite.com (mail3.registeredsite.com [64.224.9.12]) by postgresql.org (8.11.3/8.11.4) with ESMTP id f7N7mBP29599 for ; Thu, 23 Aug 2001 03:48:11 -0400 (EDT) (envelope-from jaydip@ontrackindia.com) Received: from mail.ontrackindia.com (mail.ontrackindia.com [216.247.40.229]) by mail3.registeredsite.com (8.11.4/8.11.4) with ESMTP id f7N6nj306031 for ; Thu, 23 Aug 2001 02:49:45 -0400 Received: from dewanji [216.247.40.229] by mail.ontrackindia.com (SMTPD32-6.06) id A531319E00FC; Thu, 23 Aug 2001 03:48:01 -0400 Message-ID: <000801c12ba8$5924ab40$ca00a8c0@dewanji> From: "Jaydip" To: Subject: Help On Postgresql Date: Thu, 23 Aug 2001 13:20:52 +0530 MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_NextPart_000_0005_01C12BD6.6F0AF7B0" X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 5.00.2919.6700 X-MimeOLE: Produced By Microsoft MimeOLE V5.00.2919.6700 X-Archive-Number: 200108/366 X-Sequence-Number: 4625 This is a multi-part message in MIME format. ------=_NextPart_000_0005_01C12BD6.6F0AF7B0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Dear Friends I am Jaydip Dewanji working as a Sr. Programmer for Ontrack Systems Ltd. I have some questions regarding Postgresql which are listed below: a) How do I retrieve the Year,Month,Day,Hr,Minute or Second value from a Da= te/DateTime variable. For Example : i> In Oracle to_char(dt,'yyyy') - for extracting the year= value from a date variable dt ii> In SqlServer datepart(hh,dt) - for extracting = the Hour value from a date variable dt b) Can I create an identity column in Postgresql the value of which column = will start from 1 say and keep on incrementing by 1 OR how can I serve my purpose in any other way. Please do let me know if any one of you have any solution. Regards Jaydip ------=_NextPart_000_0005_01C12BD6.6F0AF7B0 Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable
Dear Friends
 
I am Jaydip Dewanji working as a Sr. Progr= ammer for=20 Ontrack Systems Ltd.
 
I have some questions regarding Postgresql= which=20 are listed below:
 
a) How do I retrieve the Year,Month,Day,Hr= ,Minute=20 or Second value from a Date/DateTime variable.
 
    For Example : i> In = Oracle=20 to_char(dt,'yyyy') - for extracting the year value from a date variable=20 dt
       =20            =20      ii> In SqlServer datepart(hh,dt) - for extracti= ng=20 the Hour value from a date variable dt
 
b) Can I create an identity column in Post= gresql=20 the value of which column will start from 1 say and keep
    on incrementing by 1 OR= how can=20 I serve my purpose in any other way.
 
 
Please do let me know if any one of you ha= ve any=20 solution.
 
Regards
 
Jaydip
------=_NextPart_000_0005_01C12BD6.6F0AF7B0-- From aswr@gmx.de Thu Aug 30 18:02:25 2001 Received: from news.tht.net (news.hub.org [216.126.91.242]) by postgresql.org (8.11.3/8.11.4) with ESMTP id f7UI2Pf16624 for ; Thu, 30 Aug 2001 14:02:25 -0400 (EDT) (envelope-from news@news.tht.net) Received: (from news@localhost) by news.tht.net (8.11.4/8.11.4) id f7UHb5d57676 for pgsql-sql@postgresql.org; Thu, 30 Aug 2001 13:37:05 -0400 (EDT) (envelope-from news) From: Arne Weiner X-Newsgroups: comp.databases.postgresql.sql Subject: Re: Help On Postgresql Date: Thu, 30 Aug 2001 19:46:50 +0200 Organization: Hub.Org Networking Services (http://www.hub.org) Lines: 33 Message-ID: <3B8E7C0A.276F4F44@gmx.de> References: <000801c12ba8$5924ab40$ca00a8c0@dewanji> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Complaints-To: scrappy@hub.org X-Mailer: Mozilla 4.5 [en] (X11; I; Linux 2.2.18 i586) X-Accept-Language: en To: pgsql-sql@postgresql.org X-Archive-Number: 200108/368 X-Sequence-Number: 4627 Jaydip wrote: > Dear Friends > > I am Jaydip Dewanji working as a Sr. Programmer for Ontrack Systems Ltd. > > I have some questions regarding Postgresql which are listed below: > > a) How do I retrieve the Year,Month,Day,Hr,Minute or Second value from a Da= > te/DateTime variable. > > For Example : i> In Oracle to_char(dt,'yyyy') - for extracting the year= > value from a date variable dt > ii> In SqlServer datepart(hh,dt) - for extracting = > the Hour value from a date variable dt I don't know what variables you are talking about. Which interface do yo use ? My client programs recieve plain text from postgres, so there are no variables. > b) Can I create an identity column in Postgresql the value of which column = > will start from 1 say and keep > on incrementing by 1 OR how can I serve my purpose in any other way. Use the data type SERIAL. If you say e.g. CREATE TABLE mytable ( key SERIAL, .... ); Then every time you insert a new row key will increment automatically. Arne. From sszabo@megazone23.bigpanda.com Thu Aug 30 17:49:23 2001 Received: from megazone23.bigpanda.com ([216.136.151.41]) by postgresql.org (8.11.3/8.11.4) with ESMTP id f7UHnNf12172 for ; Thu, 30 Aug 2001 13:49:23 -0400 (EDT) (envelope-from sszabo@megazone23.bigpanda.com) Received: from localhost (sszabo@localhost) by megazone23.bigpanda.com (8.11.2/8.11.2) with ESMTP id f7UHnHK53901; Thu, 30 Aug 2001 10:49:17 -0700 (PDT) Date: Thu, 30 Aug 2001 10:49:17 -0700 (PDT) From: Stephan Szabo To: Jaydip cc: pgsql-sql@postgresql.org Subject: Re: Help On Postgresql In-Reply-To: <000801c12ba8$5924ab40$ca00a8c0@dewanji> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Archive-Number: 200108/373 X-Sequence-Number: 4632 On Thu, 23 Aug 2001, Jaydip wrote: > a) How do I retrieve the Year,Month,Day,Hr,Minute or Second value from a Date/DateTime variable. > > For Example : i> In Oracle to_char(dt,'yyyy') - for extracting the year value from a date variable dt > ii> In SqlServer datepart(hh,dt) - for extracting the Hour value from a date variable dt I'm not sure what versions all of these came in at, but: There is a to_char which should be somewhat compatible with oracle's, as well as a datepart (whose part names are like 'year', 'month', ...) and extract( from dt) > b) Can I create an identity column in Postgresql the value of which column will start from 1 say and keep > on incrementing by 1 OR how can I serve my purpose in any other way. Look at sequences and the serial pseudo-type. From jeckermann@verio.net Thu Aug 30 18:16:40 2001 Received: from akirason.se.verio.net (akirason.se.verio.net [204.27.64.122]) by postgresql.org (8.11.3/8.11.4) with ESMTP id f7UIGef21668 for ; Thu, 30 Aug 2001 14:16:40 -0400 (EDT) (envelope-from jeckermann@verio.net) Received: from beancounter (no-wkstns.gs.verio.net [204.27.67.225]) (authenticated) by akirason.se.verio.net (8.11.4/8.11.4) with ESMTP id f7UIGrI68900; Thu, 30 Aug 2001 13:16:54 -0500 (CDT) (envelope-from jeckermann@verio.net) Message-ID: <01d201c1317f$e0111cb0$279c10ac@INTERNAL> From: "Jeff Eckermann" To: "Jaydip" , References: <000801c12ba8$5924ab40$ca00a8c0@dewanji> Subject: Re: Help On Postgresql Date: Thu, 30 Aug 2001 13:16:13 -0500 MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_NextPart_000_01CB_01C13155.F1AC59F0" X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 5.50.4522.1200 X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4522.1200 X-Archive-Number: 200108/372 X-Sequence-Number: 4631 This is a multi-part message in MIME format. ------=_NextPart_000_01CB_01C13155.F1AC59F0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable a) Look at "Date/Time Functions" in the docs: specifically, listed under "= Functions and Operators" in the Users Guide. b) "Serial" type will do this. Look under "Numeric Types" , in the "Data T= ypes" section of the Users Guide. ----- Original Message -----=20 From: Jaydip=20 To: pgsql-sql@postgresql.org=20 Sent: Thursday, August 23, 2001 2:50 AM Subject: Help On Postgresql Dear Friends I am Jaydip Dewanji working as a Sr. Programmer for Ontrack Systems Ltd. I have some questions regarding Postgresql which are listed below: a) How do I retrieve the Year,Month,Day,Hr,Minute or Second value from a = Date/DateTime variable. For Example : i> In Oracle to_char(dt,'yyyy') - for extracting the ye= ar value from a date variable dt ii> In SqlServer datepart(hh,dt) - for extractin= g the Hour value from a date variable dt b) Can I create an identity column in Postgresql the value of which colum= n will start from 1 say and keep on incrementing by 1 OR how can I serve my purpose in any other way. Please do let me know if any one of you have any solution. Regards Jaydip ------=_NextPart_000_01CB_01C13155.F1AC59F0 Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable
a)  Look at "Date/Time Functions" in = the docs:=20 specifically, listed under "Functions and Operators" in the Users=20 Guide.
b) "Serial" type will do this.  Look = under=20 "Numeric Types" , in the "Data Types" section of the Users Guide.
----- Original Message -----
Fro= m:=20 Jaydip
To: pgsql-sql@postgresql.org
Sent: Thursday, August 23, 2001 2:= 50=20 AM
Subject: Help On Postgresql

Dear Friends
 
I am Jaydip Dewanji working as a Sr. Pro= grammer=20 for Ontrack Systems Ltd.
 
I have some questions regarding Postgres= ql which=20 are listed below:
 
a) How do I retrieve the Year,Month,Day,= Hr,Minute=20 or Second value from a Date/DateTime variable.
 
    For Example : i> I= n Oracle=20 to_char(dt,'yyyy') - for extracting the year value from a date variable= =20 dt
       =20            =20      ii> In SqlServer datepart(hh,dt) - for extrac= ting=20 the Hour value from a date variable dt
 
b) Can I create an identity column in Po= stgresql=20 the value of which column will start from 1 say and keep
    on incrementing by 1 = OR how=20 can I serve my purpose in any other way.
 
 
Please do let me know if any one of you = have any=20 solution.
 
Regards
 
Jaydip
<= /HTML> ------=_NextPart_000_01CB_01C13155.F1AC59F0-- From SHenshall@westcountrypublications.co.uk Fri Aug 31 10:20:02 2001 Received: from mail_exchange.westcountrypublications.co.uk ([195.171.163.135]) by postgresql.org (8.11.3/8.11.4) with ESMTP id f7VAK2f44300 for ; Fri, 31 Aug 2001 06:20:02 -0400 (EDT) (envelope-from SHenshall@westcountrypublications.co.uk) Received: by MAIL_EXCHANGE with Internet Mail Service (5.5.2650.21) id ; Fri, 31 Aug 2001 11:18:50 +0100 Message-ID: From: "Henshall, Stuart - WCP" To: "'Jaydip'" , pgsql-sql@postgresql.org Subject: Re: Help On Postgresql Date: Fri, 31 Aug 2001 11:18:48 +0100 MIME-Version: 1.0 X-Mailer: Internet Mail Service (5.5.2650.21) Content-Type: text/plain X-Archive-Number: 200108/376 X-Sequence-Number: 4635 a) Either of these should return the yaer (2001). See section 4.7 of the user guide SELECT EXTRACT(YEAR FROM TIMESTAMP '2001-02-16 20:38:40'); SELECT date_part('year', TIMESTAMP '2001-02-16 20:38:40'); b) The serial datatype will do this. It is actually just an int4 with a default value of nextval(''). - Stuart > -----Original Message----- > From: Jaydip [SMTP:jaydip@ontrackindia.com] > Sent: Thursday, August 23, 2001 8:51 AM > To: pgsql-sql@postgresql.org > Subject: Help On Postgresql > > Dear Friends > > I am Jaydip Dewanji working as a Sr. Programmer for Ontrack Systems Ltd. > > I have some questions regarding Postgresql which are listed below: > > a) How do I retrieve the Year,Month,Day,Hr,Minute or Second value from a > Date/DateTime variable. > > For Example : i> In Oracle to_char(dt,'yyyy') - for extracting the > year value from a date variable dt > ii> In SqlServer datepart(hh,dt) - for extracting > the Hour value from a date variable dt > > b) Can I create an identity column in Postgresql the value of which column > will start from 1 say and keep > on incrementing by 1 OR how can I serve my purpose in any other way. > > > Please do let me know if any one of you have any solution. > > Regards > > Jaydip