0

Is there any way to get the get the specific values from date such as year , month , day . Actually we have in php date function . If we give date (Y-m ) ; it will give us 2010-07 . I want like this in postgres(psql) .

Thanks in Advance...

1 Answer 1

2

SELECT to_char(CURRENT_DATE, 'MM') FROM v_use_doc_line ;

This will provide you with the month value of the CURRENT_DATE. If you need year, just replace MM with YYYY.

I hope you can guess now what you should do to get the day :).

For further information, see the to_char function of postgresql.

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

2 Comments

Use YYYY and MM: SELECT to_char(CURRENT_DATE, 'YYYY MM');

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.