3

I have a field which its format is date with time as: YYYY-MM-DD HH-MM-SS for example: 2000-08-12 00:00:00 I want to get just the date part and change its format to DD/MMM/YYYY for example the expected result of the previous example will be: 12/Aug/2000

The field definition is: Ddate timestamp without time zone DEFAULT now()

I read the whole page of Date/Time Functions and Operators and other sources as well but I couldn't find any information that is helpful.

3
  • Is it stored as a date or as a varchar? Commented Jun 17, 2015 at 7:17
  • it's timestamp see edit Commented Jun 17, 2015 at 7:20
  • 1
    Try Data Type Formatting Functions instead. Commented Jun 17, 2015 at 7:21

2 Answers 2

10

You can use the to_char function to format your column:

SELECT TO_CHAR(ddatte, 'dd/Mon/yyyy') FROM mytable
Sign up to request clarification or add additional context in comments.

Comments

4

try with:

to_char(your_Field, 'dd/mm/yyyy')

2 Comments

Yes that is what I did initially but it's not in the desired format. please note the month issue.
Minutes are called "MI" in the template patthers, not "mm" look at this site: postgresql.org/docs/8.1/static/functions-formatting.html

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.