If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > MySQL > Calculate Date when End date May Be Null

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 02-20-04, 12:42
alanhay alanhay is offline
Registered User
 
Join Date: Feb 2004
Posts: 2
Calculate Date when End date May Be Null

I'm trying to calculate the number of days between EITHER date_added and date_removed OR between date_added and today if date_removed is null.

It seems to me that I need, somehow, to get the timestamp returned by unix_timesamp(PR_DATE_ADDED) to be equal to today if it is null.

Been going round in circle with this for a few hours and geeting somewhere.

Using 3.22.

Anyone any ideas?
Reply With Quote
  #2 (permalink)  
Old 02-21-04, 13:52
aus aus is offline
Registered User
 
Join Date: Oct 2003
Location: Denver, Colorado
Posts: 137
Re: Calculate Date when End date May Be Null

I think that 3.22 supports these functions:
Code:
SELECT TO_DAYS(IFNULL(date_removed, NOW())) - TO_DAYS(date_added), ...
Reply With Quote
  #3 (permalink)  
Old 02-21-04, 14:01
alanhay alanhay is offline
Registered User
 
Join Date: Feb 2004
Posts: 2
Thanks.

Managed to get it working using the IFNULL statement.
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On