There are 2 different ways to calculate the week number: the date() function only provides for one. The other one (called "ISO") can be calculated using this function, taken from the online notes to the PHP manual (so always back to RTM): function ISOWeek($y, $m, $d) { $week=strftime("%W", mktime(0, 0, 0, $m, $d, $y)); $dow0101=getdate(mktime(0, 0, 0, 1, 1, $y)); $next0101=getdate(mktime(0, 0, 0, 1, 1, $y+1)); if ($dow0101["wday"]>1 && $dow0101["wday"]<5) $week++; if ($next0101["wday"]>1 && $next0101["wday"]<5 && $week==53) $week=1; if ($week==0) $week = ISOWeek($y-1,12,31); // return(substr("00" . $week, -2)); return($week); } HTH Francesco -----Messaggio originale----- Da: Svensson, B.A.T. (HKG) [mailto:B.A.T.Svensson@xxxxxxx] Inviato: giovedì 10 giugno 2004 10.29 A: 'Sukhwinder Singh '; 'php-windows@xxxxxxxxxxxxx ' Oggetto: RE: Problem No of weeks returned by date function I guess both function just have different interpretation (and none of them are incorrect), the best thing you can do is to translate any occurence of week 53 to week 1, that should solve your problem of losing data in the start-end case. An alternative solution is to explain for the customer how it works (that end cases always are tricky and casues problem), and tell them that "missing" data from week 1 can be found in week 53. And if they complain, then explain that "this is a complicated tech matter, but of course if you put $$.$$$:- on the table I can always fix it". -----Original Message----- From: Sukhwinder Singh To: php-windows@xxxxxxxxxxxxx Sent: 10-6-2004 20:59 Subject: Problem No of weeks returned by date function Hello, I want to display a report per week. I am facing a problem with php date function. date() function returns week 1 for a date in last year. <?php $ts = mktime(0, 0, 0, 12, 29, 2003); echo date("W", $ts); // returns 1. Is this a bug ?> But mysql week function returns 53. select week('2003-12-29', 1) I am losing the data for week 53 because I have to display week using php and then hits for that week using mysql records. I am using PHP Version 4.3.6 on Windows 2000. Is this a php bug where it is assumed that there can be just 52 weeks in a year? If yes then how mysql displays week from 0 to 53? --Sukhwinder Singh -- PHP Windows Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Windows Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Windows Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php