Hur kan man på ett smidigt sätt få reda på vilken vecka det är? T.ex. I databasen står det 2001-04-09, kan jag på något sätt få fram vilken vecka detta är?
------------------
DinDator.nu
2 svar · 219 visningar · startad av Marcus
Hur kan man på ett smidigt sätt få reda på vilken vecka det är? T.ex. I databasen står det 2001-04-09, kan jag på något sätt få fram vilken vecka detta är?
------------------
DinDator.nu
Ur mysqls dokumentation
WEEK(date)
WEEK(date,first)
With a single argument, returns the week for date, in the range 0 to 53 (yes, there may be the beginnings of a week 53), for locations where Sunday is the first day of the week. The two-argument form of WEEK() allows you to specify whether the week starts on Sunday or Monday. The week starts on Sunday if the second argument is 0, on Monday if the second argument is 1:
mysql> select WEEK('1998-02-20');
-> 7
mysql> select WEEK('1998-02-20',0);
-> 7
------------------
essentitia preter non sans multiplicandum