You are here: Re: [PHP] Date function and MySQL « PHP « IT news, forums, messages
Re: [PHP] Date function and MySQL

Posted by Arno Coetzee on 07/19/05 10:46

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

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация