For Programmers: Free Programming Magazines  


Home > Archive > PHP SQL > April 2004 > MySQL - what is the right query (in seven days -case :)









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author MySQL - what is the right query (in seven days -case :)
White Raven

2004-04-14, 5:36 am

Hi,

I'm pretty new in this section and like to ask what would be the right query
for the following:

I have a database where is date information like 2004-04-15 and so on. How
can I sort the information out the way like this: those rows where date is
"in this w" or at least the date is coming in 7 days, those will be
shown..? I hope someone understood what I'm talking about.. :D

Thanks :)




Jeppe Uhd

2004-04-14, 7:31 am

White Raven wrote:
> Hi,
>
> I'm pretty new in this section and like to ask what would be the
> right query for the following:
>
> I have a database where is date information like 2004-04-15 and so
> on. How can I sort the information out the way like this: those rows
> where date is "in this w" or at least the date is coming in 7
> days, those will be shown..? I hope someone understood what I'm
> talking about.. :D


This w:
SELECT datecol FROM datetbl WHERE
DATE_FORMAT(datecol,'%v')=DATE_FORMAT(NO
W(),'%v');

Within the next 7 days:
SELECT datecol FROM datetbl WHERE datecol>=NOW() AND datecol<=(NOW() +
INTERVAL 7 DAYS);

Both are untested...

--
MVH Jeppe Uhd - NX http://nx.dk
Webhosting for nørder og andet godtfolk


White Raven

2004-04-14, 7:31 am


"Jeppe Uhd" <inewsnospam@nx.dk> wrote in message
news:407cfde5$0$263$edfadb0f@dread11.news.tele.dk...
> White Raven wrote:
>
> This w:
> SELECT datecol FROM datetbl WHERE
> DATE_FORMAT(datecol,'%v')=DATE_FORMAT(NO
W(),'%v');
>
> Within the next 7 days:
> SELECT datecol FROM datetbl WHERE datecol>=NOW() AND datecol<=(NOW() +
> INTERVAL 7 DAYS);
>
> Both are untested...
>


I tested the first one and it works fine, the second one is not working
(something wrong in the mysql syntax I suppose). The first one is very good
solution for my purposes. :)

Thanks,

-WR




Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com