First and last date of previous month in MySql

287
Views
1
Answers

How to get first and Last date of Previous month?

edit | flag
William Patrick
Asked on: Aug 05, 2011 at 10:12PM

1 Answers

54
3
54

Try this

select date_format(curdate() - interval 1 month,'%Y-%m-01');

The output will be like

2011-07-01

To get the Last date of Previous month try this..

select date_format(last_day(curdate()-interval 1 month),'%Y-%m-%d')

The output will be like

2011-07-31
edit | flag
Gokul A
Answered on: Aug 05, 2011 at 10:15PM

Post your Answer

Search

Welcome to Ask Amoeba!
This is 100% free and interactive site for sharing professional Questions and Answers, Opensource projects, Interview questions.
Learners, beginners, Experts stop and share your knowledge and ideas!

Browse Categories

Browse Tags