0

Is it possible to use the date_part function to extract a composite of multiple specifiers?

For example, I'd like to extract the month, day of month, and hour of day from a timestamp in the single string form "month:day-of-month:hour-of-day" so that

`SELECT date_part('day', TIMESTAMP '2001-02-16 20:38:40');` 

would return "02:16:20"

1 Answer 1

1

This is much easier with to_char():

select to_char(TIMESTAMP '2001-02-16 20:38:40', 'MM:DD:HH24')

The documentation describes the formatting options.

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

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.