0

I need get only the date from now() at my time zone, I have this query:

SELECT now() AT TIME ZONE 'America/Santiago'

And I'm getting something like this "2015-06-08 23:59:34.142569" but I need extract only the date, how can I get it? Thanks.

2 Answers 2

4

If you want the server's date,

SELECT current_date;

If you need the date for any timestamp, eg the one you've gotten into your timezone, use date().

SELECT date(now() AT TIME ZONE 'America/Santiago');

Docs: http://www.postgresql.org/docs/current/static/functions-datetime.html

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks for the better doc link, @a_horse_with_no_name!
0

For postgres you want

select current_date;

if you need to extract any of those fields out of the returned value you can use extract

EXTRACT (field FROM source)

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.