G
G
gowwa1232020-10-11 18:03:40
PostgreSQL
gowwa123, 2020-10-11 18:03:40

I want the month and day columns to give out such values: 01,02,03 and so on, but not just 1,2,3 and so on, how can I do this?

Here is my request:

SELECT
  Extract(YEAR  from date::date ) AS year 
, Extract(MONTH  from date::date ) AS month 
, Extract(DAY from date::date ) AS day 
FROM sales;

Answer the question

In order to leave comments, you need to log in

1 answer(s)
0
0xD34F, 2020-10-11
@gowwa123

You can add zeros with lpad .
Or instead of using extract, format the date using the to_char method .

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question