Re: [PHP] date() and mktime() functions: weeknumbers and months.

2003-03-31 Thread Marek Kilimajer
Check out mysql manual, section 6.3.4 - Date and Time Functions, example

$condition='';
if($GET['week']) $condition .= WEEK(date)='$_GET[week]' AND ;
if($GET['year']) $condition .= YEAR(date)='$_GET[week]' AND ;
and so on
then use the condition:
$sql = SELECT * FROM news WHERE $condition 1;



Davy Obdam wrote:

Hi people,

I would like to select news from my database bases on week/year and
month/year.
How can i do this.. I would like to pass two arguments in the query
string, like news.php?week=14year=2003 or news.php?month=3year=2003.
Can anybody help me.. Thanks in advance. I have been looking at the
date() and mktime() functions, but is there anyway to determine the date
from a weeknumber? I have been using this:
$yr=2003; 
$mnth=03; 
$dy=31; 
echo base date: .$yr.-.$mnth.-.$dy.br /; 
echo last sunday: .date(Y-m-d,
mktime(0,0,0,$mnth,$dy-date(w,mktime(0,0,0,$mnth,$dy,$yr)),$yr)).br
/; 
echo next saturday: .date(Y-m-d,
mktime(0,0,0,$mnth,$dy+6-date(w,mktime(0,0,0,$mnth,$dy,$yr)),$yr)).b
r /;

$sql = SELECT * FROM news WHERE date='$last_sunday' AND
date='$next_saturday').
But i would find it better to use a weeknumber instead

Best regards,

Davy Obdam - Networking4all
Webapplication developer
E-mail: [EMAIL PROTECTED]
Web: http://www.networking4all.com 

Kijk ook eens op: http://www.verzamelgids.nl 



 



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


Re: [PHP] date() and mktime() functions: weeknumbers and months.

2003-03-31 Thread Jason Wong
On Monday 31 March 2003 22:07, Davy Obdam wrote:

 I would like to select news from my database bases on week/year and
 month/year.
 How can i do this.. I would like to pass two arguments in the query
 string, like news.php?week=14year=2003 or news.php?month=3year=2003.
 Can anybody help me.. Thanks in advance. I have been looking at the
 date() and mktime() functions, but is there anyway to determine the date
 from a weeknumber? I have been using this:

[snip]

 $sql = SELECT * FROM news WHERE date='$last_sunday' AND
 date='$next_saturday').

 But i would find it better to use a weeknumber instead

If you're using mysql you can do something like:

  SELECT * FROM news WHERE WEEK(date) = some_week_number_or_another

If you're using some other DBMS check whether it has some similar function.

-- 
Jason Wong - Gremlins Associates - www.gremlins.biz
Open Source Software Systems Integrators
* Web Design  Hosting * Internet  Intranet Applications Development *
--
Search the list archives before you post
http://marc.theaimsgroup.com/?l=php-general
--
/*
We can predict everything, except the future.
*/


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



RE: [PHP] date() and mktime() functions: weeknumbers and months.

2003-03-31 Thread Davy Obdam
Thanks Jason and Marek,

I was thinking to difficult, Thanks for the quick responses.

Best regards,

Davy Obdam

 -Oorspronkelijk bericht-
 Van: Jason Wong [mailto:[EMAIL PROTECTED] 
 Verzonden: maandag 31 maart 2003 16:36
 Aan: [EMAIL PROTECTED]
 Onderwerp: Re: [PHP] date() and mktime() functions: 
 weeknumbers and months.
 
 
 On Monday 31 March 2003 22:07, Davy Obdam wrote:
 
  I would like to select news from my database bases on week/year and 
  month/year. How can i do this.. I would like to pass two 
 arguments in 
  the query string, like news.php?week=14year=2003 or 
  news.php?month=3year=2003. Can anybody help me.. Thanks in 
 advance. I 
  have been looking at the
  date() and mktime() functions, but is there anyway to determine the 
  date from a weeknumber? I have been using this:
 
 [snip]
 
  $sql = SELECT * FROM news WHERE date='$last_sunday' AND 
  date='$next_saturday').
 
  But i would find it better to use a weeknumber instead
 
 If you're using mysql you can do something like:
 
   SELECT * FROM news WHERE WEEK(date) = some_week_number_or_another
 
 If you're using some other DBMS check whether it has some 
 similar function.
 
 -- 
 Jason Wong - Gremlins Associates - www.gremlins.biz
 Open Source Software Systems Integrators
 * Web Design  Hosting * Internet  Intranet Applications 
 Development *
 --
 Search the list archives before you post 
 http://marc.theaimsgroup.com/?l=php-general
 
 --
 /*
 We can predict everything, except the future.
 */
 
 
 -- 
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php
 
 
 Deze e-mail is door E-mail VirusScanner van Planet Internet 
 gecontroleerd op virussen. Op http://www.planet.nl/evs staat 
 een verwijzing naar de actuele lijst waar op wordt gecontroleerd.
 
 



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