Re: Function to convert bigint to date

From: Steven Klassen <sklassen(at)commandprompt(dot)com>
To: "Pradeepkumar, Pyatalo (IE10)" <Pradeepkumar(dot)Pyatalo(at)honeywell(dot)com>
Cc: pgsql-novice(at)postgresql(dot)org
Subject: Re: Function to convert bigint to date
Date: 2004-10-26 03:46:36
Message-ID: 20041026034636.GA23780@commandprompt.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

* Pradeepkumar, Pyatalo (IE10) <Pradeepkumar(dot)Pyatalo(at)honeywell(dot)com> [2004-10-25 02:23:19 -0700]:

> But from the result I need to display only the date and not the
> time. Should I use extract() function to get the day, month and year
> seperately and then form the date format, or is there any other way
> to extract only the date part from the timestamp.

You can cast a timestamp to a date. You really need to give these
things a try yourself. You'd be surprised what you can figure out
through trial and error.

xinu=> select now()::timestamp;
now
----------------------------
2004-10-25 23:45:38.939148
(1 row)

xinu=> select (now()::timestamp)::date;
now
------------
2004-10-25
(1 row)

--
Steven Klassen - Lead Programmer
Command Prompt, Inc. - http://www.commandprompt.com/
PostgreSQL Replication & Support Services, (503) 667-4564

In response to

Browse pgsql-novice by date

  From Date Subject
Next Message Sean Davis 2004-10-26 11:12:36 Simple function question
Previous Message Pradeepkumar, Pyatalo (IE10) 2004-10-26 03:38:12 Re: Function to convert bigint to date