What should be the query if i would like to find the week of the month from Y-m-d format.?
For Example:
If i would like to know which week is running on month of 2007-03-12 (the answer is 2nd week)
How to perform such query in SQL ?
Thanks in advance to all of YOU!!
how to find the week of the month?
Moderator: General Moderators
- dibyendrah
- Forum Contributor
- Posts: 491
- Joined: Wed Oct 19, 2005 5:14 am
- Location: Nepal
- Contact:
Easy using mysql builtin function.
Code: Select all
mysql> SELECT YEAR('2007-03-12');
-> 1998
actually we have 2007 in 2007dibyendrah wrote:Easy using mysql builtin function.Code: Select all
mysql> SELECT YEAR('2007-03-12'); -> 1998
Code: Select all
SELECT Week('2007-03-12')Pardon me i think you didnt get my question
One more time:
I want ans 2 for the case 2007-03-12 because the March - 12 means 2nd week running..I dont want the ans 10 because its the total week from the start of the year....
I would like to find the week of the month
Hope my question is clear..If not feel free to comment..
Thanks in advance to all of You!!
One more time:
I want ans 2 for the case 2007-03-12 because the March - 12 means 2nd week running..I dont want the ans 10 because its the total week from the start of the year....
I would like to find the week of the month
Hope my question is clear..If not feel free to comment..
Thanks in advance to all of You!!
Haven't seen a built-in function for that but tryit returns 2 which i would interpret as "third week".
Code: Select all
SELECT Week('2007-03-12')-Week('2007-03-01')