Count the days since .... DateDiff

liunx

Guest
With advance apologies - I'm a newbie! This is probably very easy ..... I want this Excel formula:<br />
<br />
DaysNumber=DATEDIF("03-Sept-2003",NOW(),"d") <br />
<br />
It gives me the number of days that have elapsed since the 3rd September. I've tried all permutations of DATEDIFF that I can think of, but I'm doing something horribly wrong! :confused: <br />
<br />
PLEASE can somebody help????!!!! <br />
<br />
Thanks <br />
Cherry<!--content-->This is an HTML forum, you're not likely to get an answer here.:eek:<!--content-->.... now I feel even more stupid!<br />
<br />
Er, what language should I be looking at to put a calculated field into an HTML page?<br />
<br />
[Cringing with embarrassement]<br />
<br />
C<!--content-->A mistake is a sign that someone has tried to do something. Keep trying, I think a PHP script could do what you are after. I am a PHP newbie, but will have a go myself, give me a few hours. :D <br />
gizmo<!--content-->CherryAA, have a look at <!-- m --><a class="postlink" href="http://www.php.net/manual/en/ref.datetime.php">http://www.php.net/manual/en/ref.datetime.php</a><!-- m --> while you are waiting...:D<!--content-->Originally posted by gizmo <br />
A mistake is a sign that someone has tried to do something. Keep trying,:D <br />
<br />
That's a really nice thing to say! Thanks :)<br />
<br />
Am checking your link now ......<br />
<br />
Cx<!--content-->You can try something like this:<br />
<br />
<?PHP<br />
$today = time();<br />
$date = "09-03-2003";<br />
list ($month, $day, $year) = preg_split("/[\\/-]/", $date);<br />
$date= mktime (0,0,0,$month,$day,$year);<br />
$diff = floor(($today - $date)/60/60/24);<br />
echo "$diff days different";<br />
?><!--content-->Grrr, how annoying. That looks like it should work, but it just disappeared on my page. Maybe I need to wrap it up more ... I'll try again later!<br />
<br />
Thank you both for your help & tolerance!<br />
<br />
C :)<!--content-->Does your server support PHP?<!--content-->I can whip something up in asp.net if your server happens to support that :) But asp.net hosting is not as common and you would probably know if your host supported it :rolleyes:<!--content-->... for all the replies!<br />
<br />
I still don't know why Pyro's script didn't work, but I eventually found a javascript in the javascript Source :rolleyes: that was easily modified to return days. It's still counting.<br />
<br />
Cheers :)<!--content-->I use a JS script by Alan Palmer to count days since a date in the past and days until a date in the future. You can see the code in action at <!-- m --><a class="postlink" href="http://hammerlogic.com">http://hammerlogic.com</a><!-- m --><!--content-->The poem about this forum I am making up on the fly<br />
and then another thread <br />
came back from the dead<!--content-->
 
Back
Top