Re: Date function and MySQL

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Philip Thompson wrote:

Hi all.

I have the week number (for example, this is the 29th week of the year and it begins on 7/17/05). Does anyone know how to obtain the first (and maybe the last) date of the week if you only know the week number of the year? Would it be better for me to obtain this in PHP or MySQL? or both?

I have researched the archives on a few lists and I know that others have asked this same questions, but I have not found a good solution. I have also looked on MySQL's "date and time functions" page, but had little luck.

Any thoughts would be appreciated.
~Philip

Hi Philip

give this a go... i played around with the date functions of mysql

select date_sub(curdate() , interval (date_format(curdate() , '%w')-1) day) as firstday , date_add(curdate() , interval (7 - date_format(curdate() , '%w')) day) as lastday

it will give you the date of the monday and the sunday of the current week

hope this solves your problem.

Arno

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux