By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
437,660 Members | 1,267 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 437,660 IT Pros & Developers. It's quick & easy.

extracting date FROM timestamp

P: n/a
Hi;
Please. Could you tell me the more simple way to extract the 'date' part of a
timestamp value.
I guess we could extract the year, month, and day subfields and concatenate
them. But, isn't there a more direct way?

Best regards,

Javier

---------------------------(end of broadcast)---------------------------
TIP 1: subscribe and unsubscribe commands go to ma*******@postgresql.org

Nov 12 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
Javier,

Try casting, like so:
select current_timestamp::date;
(note, pgsql won't be able to use an index for a casted field)

Best regards,

Arjen

javier garcia - CEBAS wrote:
Hi;
Please. Could you tell me the more simple way to extract the 'date' part of a
timestamp value.
I guess we could extract the year, month, and day subfields and concatenate
them. But, isn't there a more direct way?

Best regards,

Javier

---------------------------(end of broadcast)---------------------------
TIP 1: subscribe and unsubscribe commands go to ma*******@postgresql.org



---------------------------(end of broadcast)---------------------------
TIP 7: don't forget to increase your free space map settings

Nov 12 '05 #2

P: n/a
Hello

tsearch2=# select extract(day from current_timestamp);
date_part
-----------
22

or

tsearch2=# select to_char(timestamp 'now','YY DD MM HH12:MI:SS');
to_char
-------------------
03 22 12 12:28:46
(1 dka)

Regards
Pavel

On Mon, 22 Dec 2003, javier garcia - CEBAS wrote:
Hi;
Please. Could you tell me the more simple way to extract the 'date' part of a
timestamp value.
I guess we could extract the year, month, and day subfields and concatenate
them. But, isn't there a more direct way?

Best regards,

Javier

---------------------------(end of broadcast)---------------------------
TIP 1: subscribe and unsubscribe commands go to ma*******@postgresql.org

---------------------------(end of broadcast)---------------------------
TIP 5: Have you checked our extensive FAQ?

http://www.postgresql.org/docs/faqs/FAQ.html

Nov 12 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.