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




FW: Date and Mysql... (now complete)

2002-04-10 Thread Christian Pfeiffer

(one should not mess up strg and shift :-/)

 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

SELECT DATE, DATE_FORMAT(DATE, '%M %D, %Y') AS DATE2, 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

Similar thing. Date_format(NULL, '%M %D, %Y') should return 00 00, 00,
iirc, and thus is not NULL even if your date column is.  

SELECT DOB, DATE_FORMAT(DOB, '%M %D, %Y') as DOB2, 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

HTH,

Chris 


-
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: 2 queries in one?

2002-01-02 Thread Christian Pfeiffer

Should be something like

Select Status, Date from Table where Status  closed or Date  now()
- 14

(This is from memory so please dont rely on the syntax ;-)

HTH,

Chris

-- 

Christian Pfeiffer
Smart-Link Gesellschaft für EDV-Systemlösungen mbH
Herforder Str. 5-7   www.smart-link.de
33602 Bielefeld   Fon 0521-9623716
[EMAIL PROTECTED]   Fax 0521-9623721 

 
 I've looked through the docs and I couldn't find out how
 to do this.  If you can point me to the right place in the
 documentation so I can read how, that would be great. If
 you could give me a little sample query to start from, that
 would be great as well.
 
 I've 2 columns in a table.  Status and Date.  I want to
 select all rows regardless of the values in either.  However,
 if the status is closed, I only want those closed records
 that are less than 2 weeks old.  
 Can this be done in one query?  If so, how?  And where
 can I read how to do this in the docs?
 
 thnx,
 Chris


-
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