Thursday, 15 May 2014

How to get last Sunday of previous year, if we enter any date in MySQL? -



How to get last Sunday of previous year, if we enter any date in MySQL? -

ex. if come in today's date 2014-06-23 should show me previous year's lastly sunday date i.e. 2013-12-29. should not utilize procedure / sub-queries, should single query. im using mysql. kindly help.

try this:

select (date(now()) - interval dayofweek(now()) - 1 day) - interval (weekofyear(now()) - 1) * 7 day

mysql

No comments:

Post a Comment