¡¡

 | Home | CarCare | Game | Life | Business | 


difference between two dates
¡¡¡¡¡¡IN FOCUS main

¡¤Hosted streaming media sol¡­
¡¤Limited company T/as A, B ¡­
¡¤Windows 98SE and wifi prob¡­
¡¤Windows live mail question
¡¤Whats wrong with .org.uk
¡¤Difference between two dat¡­
¡¤Monitoring your website...¡­
¡¤Routers getting hot
¡¤Domain Name - Chinese Cont¡­
¡¤Anyone using UK2 web hosti¡­
¡¤SEO Info
¡¤Magazine Subscription Webs¡­
¡¤small business website des¡­
¡¤The curse of firefox...
¡¤Spiders
¡¤File Hosting/Developer nee¡­
¡¤Freezing HDs
¡¤Ehosting.co.uk with SSL, A¡­
¡¤Why is my main content mis¡­
¡¤Unified Messaging, VoIP an¡­
¡¤What is the tool called th¡­
¡¤Corel Draw X4
¡¤Outlook 07 sent emails in ¡­
¡¤PC Dead - me thinks!!
¡¤Weblinx  - SEO - SITE BOOS¡­
difference between two dates

Position: Home >> Life >> Computers >> ÕýÎÄ ¡¡
Hi UKBF'ers!

Can anyone help?

Trying to work out how to get the difference (in days) between two dates. One stored in a MySQL4 database and today's.

Using PHP and MySql - Any help appreciated.
=============
Try this

It will only work if you have stored the dates as “YYYY-MM-DD” [standard format] in the db

<?

function daysDiff($endDate, $beginDate)
{

//explode the date by "-" and storing to array
$date_parts1=explode("-", $beginDate);
$date_parts2=explode("-", $endDate);


$start_date=gregoriantojd($date_parts1[1], $date_parts1[2], $date_parts1[0]);
$end_date=gregoriantojd($date_parts2[1], $date_parts2[2], $date_parts2[0]);
return $end_date - $start_date;
}

?>
To use just pull the dates from the DB into this

<?php

//todays and yesterdays date
echo daysDifference('2008-05-13','2008-05-12');
?>
=============
Try this

It will only work if you have stored the dates as “YYYY-MM-DD?[standard format] in the db

To use just pull the dates from the DB into this

That's worked a treat. Many thanks!
=============
Gotta love ColdFusion for simplifying stuff ;)

DateDiff("datepart", "date1", "date2")
http://livedocs.adobe.com/coldfusion/7/htmldocs/wwhelp/wwhimpl/common/html/wwhelp.htm?context=ColdFusion_Documentation&file=00000440.htm
=============
Gotta love ColdFusion for simplifying stuff ;)


http://livedocs.adobe.com/coldfusion/7/htmldocs/wwhelp/wwhimpl/common/html/wwhelp.htm?context=ColdFusion_Documentation&file=00000440.htm

Are you being serious? :O

Something I mayjust learn. I take it a special server is needed to run its code?
=============
Gotta love ColdFusion for simplifying stuff ;)



Phil,

A very early project I worked on was joke site that emailed out a joke a day. Using cold fusion I did just as above so it only emailed out 1 joke a day. However in CF 4 I think it was the datediff had a bug in it so when Jan 1 came around it did not see the difference as 1 from previous day but 364. As the logic in the code was not very strong it started sending out jokes in a never ending loop. It eventually crashed my hosts mail server and some people got like 10k jokes emailed to them.

Needless to say the joke wore thin and bust-a-gut.com ( i think that was the domain ) was no more.

:p
=============
Are you being serious? :O

Something I mayjust learn. I take it a special server is needed to run its code?
You can download a free development server from Adobe and then you just need to find a reliable ColdFusion host (http://www.openmindhosting.co.uk/uk-coldfusion-web-hosting.cfm) ;)
Phil,

A very early project I worked on was joke site that emailed out a joke a day. Using cold fusion I did just as above so it only emailed out 1 joke a day. However in CF 4 I think it was the datediff had a bug in it so when Jan 1 came around it did not see the difference as 1 from previous day but 364. As the logic in the code was not very strong it started sending out jokes in a never ending loop. It eventually crashed my hosts mail server and some people got like 10k jokes emailed to them.

Needless to say the joke wore thin and bust-a-gut.com ( i think that was the domain ) was no more.

:p
Ah I broke my teeth on CF4 ;)

Moved on a lot since then and you can always get round those natty server crashes by adding checking code :p
=============
Hmm.. I might have a play with CF! Never touched it before as I've always believed VB, PHP, or Perl would do better!
=============
Well in my mind there is no "best" language really, it's what you feel most comfortable working with and what works best for you...

The reason I went with CF was its simplicity combined with power although the licensing costs for servers when you want to offer it as a hosting platform make my eyes water every time I put a new box online ;)
=============
Well in my mind there is no "best" language really, it's what you feel most comfortable working with and what works best for you...

The reason I went with CF was its simplicity combined with power although the licensing costs for servers when you want to offer it as a hosting platform make my eyes water every time I put a new box online ;)

You probably already know about this but if not might give you some options

http://www.newatlanta.com/products/bluedragon/index.cfm
=============
Yup I've been aware of BlueDragon for a number of years however the last time I checked (although this could have changed now) there wasn't an equivalent of the sandboxing facility as in CF enterprise which is obviously essential for shred hosts...
=============
Gotta love ColdFusion for simplifying stuff ;)

Quote:
datediff("datepart", "date1", "date2")

So far as I'm aware you can use the datediff function in mysql easily enough. For example:
select datediff( now(), field) from table; where the field is a date formatted field. Alternatively (if you want to test your own date...
select datediff( now(), '2007-05-14') from table where RESTRICTION = x;

Of course if you want to count the number of business days between two dates, then you have to be a bit more clever, and deduct all those Saturdays and Sundays, plus any holidays (possibly by utilising a holidays lookup table).
=============
  • Previous ArticleNews :

  • Next ArticleNews :


  • Example Unordered List

    Hosted streaming media sol¡­
    Windows 98SE and wifi prob¡­
    small business website des¡­
    The curse of firefox...
    Why is my main content mis¡­
    Unified Messaging, VoIP an¡­
    Smile - youre on candid ca¡­
    Permanent Redirect Not Fou¡­
    Radio Button Question
    Creating a more efficient ¡­


    Top A browser built for speed, stability and security
    | repair slow computer | Link | Copyright |