Re: Date and Mysql...

2002-04-10 Thread Alexander Skwar

»Chuck PUP Payne« sagte am 2002-04-10 um 10:27:19 -0400 :
> going 9, 8, 5, 10 on the dates. Here is the SQL statement I am using...

That's because your DATE which you've made with DATE_FORMAT is treated
as string.  To fix it, I'd write:

> SELECT DATE_FORMAT(DATE, '%M %D, %Y') AS DATE, Title, Links, Summary FROM
> news WHERE TO_DAYS(NOW()) - TO_DAYS(DATE) <=5 ORDER BY DATE DESC

SELECT DATE_FORMAT(DATE, '%M %D, %Y') AS DATE_DSP, DATE, Title, Links, Summary FROM
news WHERE TO_DAYS(NOW()) - TO_DAYS(DATE) <=5 ORDER BY DATE DESC

This way, you can display the "nicely" formated date in DATE_DSP and
still got a "good" copy of date around.

Alexander Skwar
-- 
How to quote:   http://learn.to/quote (german) http://quote.6x.to (english)
Homepage:   http://www.iso-top.de  | Jabber: [EMAIL PROTECTED]
   iso-top.de - Die günstige Art an Linux Distributionen zu kommen
   Uptime: 21 hours 52 minutes

-
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/   (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php




Re: Date and Mysql...

2002-04-10 Thread Gerald Clark

Your alias and column name are the same.
Which one do you think is being tested?

Also DATE is a reserved word.

Chuck \"PUP\" Payne wrote:

>Hi again...
>
>When I felt proud because last week I had asked about how to use NOW(), and
>get answer that got me working, but now I have a strange problem. It listing
>dates, but it not listing like it should, when the web page is create it
>going 9, 8, 5, 10 on the dates. Here is the SQL statement I am using...
>
>
>SELECT DATE_FORMAT(DATE, '%M %D, %Y') AS DATE, Title, Links, Summary FROM
>news WHERE TO_DAYS(NOW()) - TO_DAYS(DATE) <=5 ORDER BY DATE DESC
>
>Another problem I am having with another statement. The following statement
>should list birthdays that are 7 days out but it not...
>
>SELECT DATE_FORMAT(DOB, '%M %D, %Y') as DOB, Fname, Lname, Email FROM
>emply_info WHERE (TO_DAYS(DOB) - TO_DAYS(NOW()))
><=5 AND (TO_DAYS(DOB) >= TO_DAYS(NOW())) and Tdate is NULL and DOB is not
>null ORDER BY DOB, Lname
>
>Any clue why my SQL statement worked once are now not working?
>
>Thanks a head of time.
>
>Chuck Payne
>Magi Design and Support
>
>
>
>-
>Before posting, please check:
>   http://www.mysql.com/manual.php   (the manual)
>   http://lists.mysql.com/   (the list archive)
>
>To request this thread, e-mail <[EMAIL PROTECTED]>
>To unsubscribe, e-mail 
><[EMAIL PROTECTED]>
>Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php
>
>



-
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/   (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php




RE: Date and Mysql...

2002-04-10 Thread Christian Pfeiffer

> Hi again...

Hi,
 
> When I felt proud because last week I had asked about how to 
> use NOW(), and
> get answer that got me working, but now I have a strange 
> problem. It listing
> dates, but it not listing like it should, when the web page 
> is create it
> going 9, 8, 5, 10 on the dates. Here is the SQL statement I 
> am using...
> 
> 
> SELECT DATE_FORMAT(DATE, '%M %D, %Y') AS DATE, Title, Links, 
> Summary FROM
> news WHERE TO_DAYS(NOW()) - TO_DAYS(DATE) <=5 ORDER BY DATE DESC

Date_format returns a string, so 10 is indeed "below" 5.

You could try something like



> Another problem I am having with another statement. The 
> following statement
> should list birthdays that are 7 days out but it not...
> 
> SELECT DATE_FORMAT(DOB, '%M %D, %Y') as DOB, Fname, Lname, Email FROM
> emply_info WHERE (TO_DAYS(DOB) - TO_DAYS(NOW()))
> <=5 AND (TO_DAYS(DOB) >= TO_DAYS(NOW())) and Tdate is NULL 
> and DOB is not
> null ORDER BY DOB, Lname
> 
> Any clue why my SQL statement worked once are now not working?
> 
> Thanks a head of time.
> 
> Chuck Payne
> Magi Design and Support
> 
> 
> 
> -
> Before posting, please check:
>http://www.mysql.com/manual.php   (the manual)
>http://lists.mysql.com/   (the list archive)
> 
> To request this thread, e-mail <[EMAIL PROTECTED]>
> To unsubscribe, e-mail 
> <[EMAIL PROTECTED]>
> Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php
> 
> 


-
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/   (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php