MySQL Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsDatabasesMySQL Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old March 2nd, 2005, 06:29 AM
il_duce il_duce is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Feb 2005
Posts: 5 il_duce User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 39 m 31 sec
Reputation Power: 0
return value for date_format() when date field is NULL

Hi,

I cant find the answer on the manual pages. Maybe I should look harder.

Basically I'm putting dates into a table using:
Code:
date_format(INVOICEDATE, '%Y-%m-%d %H:%i:%s') As datei


then I can select dates that have put an INVOICEDATE in by doing
Code:
SELECT * FROM TABLE WHERE datei>'1'


Only the reverse doesnt work, meaning I cant do a query for rows where no invoice date was entered (i.e. null)

So I need to know exactly what value the date_format function returns when it comes accross a null value. I've tried echoing the result to the screen and it returns an empty string.

Reply With Quote
  #2  
Old March 28th, 2005, 11:28 AM
gertcuppens's Avatar
gertcuppens gertcuppens is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: May 2004
Posts: 118 gertcuppens User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 17 h 28 m
Reputation Power: 5
This question was so intriguing I looked into my own database.
And indeed, if i looked for the records

select * from film where taal = null
I got not a single record, although I knew there had to be some.

Here's what I found at http://mysqld.active-venture.com/Pr..._with_NULL.html
If you want to search for column values that are NULL, you cannot use the =NULL test. The following statement returns no rows, because expr = NULL is FALSE, for any expression:

mysql> SELECT * FROM my_table WHERE phone = NULL;To look for NULL values, you must use the IS NULL test. The following shows how to find the NULL phone number and the empty phone number:

mysql> SELECT * FROM my_table WHERE phone IS NULL;mysql> SELECT * FROM my_table WHERE phone = "";And so I changed my SQL statement
Select * from film where taal = null
into
select * from film where taal is null

and this time, I got the records I expected.

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsDatabasesMySQL Development > return value for date_format() when date field is NULL


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 4 hosted by Hostway