pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
Help On Postgresql
5+ messages / 5 participants
[nested] [flat]

* Help On Postgresql
@ 2001-08-23 07:50  Jaydip <jaydip@ontrackindia.com>
  0 siblings, 3 replies; 5+ messages in thread

From: Jaydip @ 2001-08-23 07:50 UTC (permalink / raw)
  To: pgsql-sql

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

^ permalink  raw  reply  [nested|flat] 5+ messages in thread

* Re: Help On Postgresql
@ 2001-08-30 17:46  Arne Weiner <aswr@gmx.de>
  parent: Jaydip <jaydip@ontrackindia.com>
  2 siblings, 0 replies; 5+ messages in thread

From: Arne Weiner @ 2001-08-30 17:46 UTC (permalink / raw)
  To: pgsql-sql

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.



^ permalink  raw  reply  [nested|flat] 5+ messages in thread

* Re: Help On Postgresql
@ 2001-08-30 17:49  Stephan Szabo <sszabo@megazone23.bigpanda.com>
  parent: Jaydip <jaydip@ontrackindia.com>
  2 siblings, 0 replies; 5+ messages in thread

From: Stephan Szabo @ 2001-08-30 17:49 UTC (permalink / raw)
  To: Jaydip <jaydip@ontrackindia.com>; +Cc: pgsql-sql

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(<part> 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.





^ permalink  raw  reply  [nested|flat] 5+ messages in thread

* Re: Help On Postgresql
@ 2001-08-30 18:16  Jeff Eckermann <jeckermann@verio.net>
  parent: Jaydip <jaydip@ontrackindia.com>
  2 siblings, 0 replies; 5+ messages in thread

From: Jeff Eckermann @ 2001-08-30 18:16 UTC (permalink / raw)
  To: Jaydip <jaydip@ontrackindia.com>; pgsql-sql

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 Types" section of the Users Guide.
  ----- Original Message ----- 
  From: Jaydip 
  To: pgsql-sql@postgresql.org 
  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 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

^ permalink  raw  reply  [nested|flat] 5+ messages in thread

* Re: Help On Postgresql
@ 2001-08-31 10:18  Henshall, Stuart - WCP <SHenshall@westcountrypublications.co.uk>
  0 siblings, 0 replies; 5+ messages in thread

From: Henshall, Stuart - WCP @ 2001-08-31 10:18 UTC (permalink / raw)
  To: 'Jaydip' <jaydip@ontrackindia.com>; pgsql-sql

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('<sequence name>').
- 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



^ permalink  raw  reply  [nested|flat] 5+ messages in thread


end of thread, other threads:[~2001-08-31 10:18 UTC | newest]

Thread overview: 5+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2001-08-23 07:50 Help On Postgresql Jaydip <jaydip@ontrackindia.com>
2001-08-30 17:46 ` Arne Weiner <aswr@gmx.de>
2001-08-30 17:49 ` Stephan Szabo <sszabo@megazone23.bigpanda.com>
2001-08-30 18:16 ` Jeff Eckermann <jeckermann@verio.net>
2001-08-31 10:18 Re: Help On Postgresql Henshall, Stuart - WCP <SHenshall@westcountrypublications.co.uk>

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