0

I want to to select the time of a date from database. How can I do this using postgresql database?

3 Answers 3

1

You can use the date_part function, like this:

date_part('hour', timestamp '2001-02-16 20:38:40')

This would give you 20 for example.

For more information, refer to http://www.postgresql.org/docs/8.2/interactive/functions-datetime.html

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

Comments

0

Not sure what you exactly mean. Perhaps answer to your question is:

select now();

or maybe it's:

select now()::time;

Comments

0

Maybe:

select to_char (field, 'HH24:MI:SS') FROM table;

Example:

select to_char ('2011-04-13 11:22:33'::timestamp, 'HH24:MI:SS');

It gives you:

11:22:33

Replace

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.