List:General Discussion« Previous MessageNext Message »
From:Barry Date:May 18 2006 12:00pm
Subject:Re: duration query: how to ?
View as plain text  
Bedford Bob schrieb:
> Hi,
> 
> My clients can put their articles on my website. They pay for the real
> utilisation of the site. If a client has used 2 slots for all year, then he
> pays for them.
> 
> Now my articles table has a starddate (when the client has started to sell
> his product) and an enddate (when the article is sold).
> 
> I'd like to retrieve the total amount of time the articles have been in the
> site from 2005-01-01 to 2005-01-31 and divide them by 365 (or 366 if leap
> year).
> 
> if an article has been online from 2004-10-01 to null (meaning the article
> hasn't been sold yet) then I may count 365 days
> 
> How to do so with a query ? fields are client.idclient, article.idclient,
> article.idarticle, article.startdate, article.enddate.
> 
> Please help me, I don't know how to retrieve those values and I need 
> them to
> get payed.
> 
> Bob
> 
> 
Use the DIF functions.

What version of MySQL do you have?

An other way would be to convert the Dates into UNIX STAMPS
that way you could subtract them and you have then the seconds between 
each date.

I don't think i have to tell you how to go on then.

Greets
	Barry

-- 
Smileys rule (cX.x)C --o(^_^o)
Dance for me! ^(^_^)o (o^_^)o o(^_^)^ o(^_^o)
Thread
duration query: how to ?Bedford Bob18 May
  • Re: duration query: how to ?Barry18 May
  • Re: duration query: how to ?Peter Brawley18 May
  • Re: duration query: how to ?John Hicks18 May