aldweb

Close I. aldweb

Close II. PC Freeware

Close III. Palm Freeware

Close IV. Palm Shareware

Close V. iziBasic Palm

Close VI. Palm Knowledge

Close VII. Pocket Computer

Close VIII. miniPortail

Special !



Mobile version of
the aldweb Site

m.aldweb.com


Neither French, nor English?

Try one of these flags then:
[de] [es] [it] [pt]
Search




Weather / Spam / www

Lyon Weather


aldweb against spam


Newsletter
To receive news about this website, consider subscribing to our Newsletter.
Subscribe
Unsubscribe
298 Subscribers
Family's web sites

Webmaster - Infos
Friends News
Visits

   visitors

   visitors online

Poll
What do you think of the new design of the aldweb Site?
 
Great !
Beautiful
Average
So ugly...
Results
forum.gifForum - iziBasic - Topic #1356

Forum - Forum
iziBasic - iziBasic


Warning: A non-numeric value encountered in /web5/aldweb/www/aldweb_com/www/thread.php on line 257

active  Topic # 1356  DateDiff Function

01/02/2006 @ 11:35
by André

Anonymous



I am looking for a way to calculate the number of actual days between two dates. Anybody have a function or source code I can use?
Write to André   Post an answer  Top

[]   


Warning: A non-numeric value encountered in /web5/aldweb/www/aldweb_com/www/thread.php on line 497
Answer n° 1
--------
01/02/2006 @ 17:03
by Nevin

Anonymous

visitor
I have a built a timer that I use in a few programs from the TIME$­­ function a similar program could be made using DATE$­­. The code for my timer is fairly long. I use CHARS (c!t, n!n) to pull individual characters out of the string given by TIME$­­. Then I convert them to numerical values with VAL and then use some basic math to convert and combine them into a useable time value. I will give you my code if you can't figure it out, but I am sure that Aldweb or Khertan have an easier solution. I am just a newbie.
Nevin
Write to Nevin   Post an answer  Top

Warning: A non-numeric value encountered in /web5/aldweb/www/aldweb_com/www/thread.php on line 497
Answer n° 2
--------
02/02/2006 @ 20:24
by aldweb

Anonymous

visitor
Khertan should come to the rescue pretty soon...

Cheers,
aldweb
Write to aldweb   Post an answer  Top

Warning: A non-numeric value encountered in /web5/aldweb/www/aldweb_com/www/thread.php on line 497
Answer n° 3
--------
02/02/2006 @ 20:52
by Khertan

Anonymous

visitor
Héhé ... two seconds ... i must dig in my backup to find it :)

Write to Khertan   Post an answer  Top

Warning: A non-numeric value encountered in /web5/aldweb/www/aldweb_com/www/thread.php on line 497
Answer n° 4
--------
02/02/2006 @ 21:07
by Khertan

Anonymous

visitor
Well i can't found it ... maybe on some general backup ... but i can t access it today ... my linux isn't totally configurated yet ...

but i know this method was very slow, and take 2100 line of code ... not very well optimized but entirely in iziBasic ...

But i can send you tommorrow an pp applet that do that more efficiently ...

in 20 or 30 lines of codes :)

just one things, do you want to count entire days only ? or with fraction ? :)

See you later ... i ll do that tomorrow morning in public transport :)
Write to Khertan   Post an answer  Top

Warning: A non-numeric value encountered in /web5/aldweb/www/aldweb_com/www/thread.php on line 497
Answer n° 5
--------
03/02/2006 @ 05:15
by Nevin

Anonymous

visitor
Here is some source code for a short program that I developed to access count days through Izibasic. Note: You will need to somehow save the start and end time in Saved Prefs for it to work for practical applications as you probably will not leave your handheld running the same app for days at a time.

Code Start:
' DATE.ibas
{CREATORID "DATE"}
{VERSION "1.0"}
'{MINOSVERSION "3.0"}
'{PARSER OFF}
'{KEYEVENTS OFF}
'{SECUREFILES ON}

BEGIN
'START DAY
A$­­=DATE$­­
'Day
B$­­=CHAR$­­(A$­­, 2)
B=VAL(B$­­)
'Ten Day
C$­­=CHAR$­­(A$­­, 1)
C=VAL(C$­­)
'TOTAL DAYS START
D=C*10+B
PRINT "You started on the"
PRINT D USING 0
PRINT "of the month."
WAIT

REPEAT
Z=DOEVENTS
E$­­=DATE$­­
'Day
F$­­=CHAR$­­(E$­­, 2)
F=VAL(F$­­)
'Ten Day
G$­­=CHAR$­­(E$­­, 1)
G=VAL(G$­­)
'TOTAL DAYS START
H=G*10+F
'Account for start near the end of the month
IF D>H THEN H=H+31
ENDIF
'Calculate the difference between start and finish time
I=H-D
'Display elaped days.
PRINT "There have been"
PRINT I USING 0
PRINT "days since it started."
IF I>15 THEN GOSUB _EXPIRED
ENDIF
PRINT "Type Exit to end!"
PRINT "Anything else to check again."
INPUT X$­­
IF X$­­="Exit" THEN Z=-1
ENDIF
UNTIL Z=-1
END


_EXPIRED:
'Makes expired in 15 days.
PRINT "15 days is up!"
END




Code End

You can download this and my other Timer program and source code from :
http://www.morrisonmuscle.com/software.htm
I am not sure if this is what you are looking for, but they can work well for handling simple time/timer needs in Izibasic.
Nevin
Write to Nevin   Post an answer  Top

Warning: A non-numeric value encountered in /web5/aldweb/www/aldweb_com/www/thread.php on line 497
Answer n° 6
--------
04/02/2006 @ 17:23
by aldweb

Anonymous

visitor
Nevin,

If you just want to test for a trial period, you better take it easy with a small routine that would roughly estimate all months to be 31 days and add the number of current days on top of 31 minus start day if ever current month is 1 over start month, this for a trial period minor than one month.

Cheers


@+
aldweb
Write to aldweb   Post an answer  Top

Warning: A non-numeric value encountered in /web5/aldweb/www/aldweb_com/www/thread.php on line 497
Answer n° 7
--------
05/02/2006 @ 01:10
by Nevin

Anonymous

visitor
Yeah,
I know that the 31 day thing was not perfect. I just did not want to take the time to account for the rare case. I was a little lazy. I was just making the program as a small example of how it could be done. I know with a little more code I could have made it better.
Write to Nevin   Post an answer  Top

Warning: A non-numeric value encountered in /web5/aldweb/www/aldweb_com/www/thread.php on line 497
Answer n° 8
--------
05/02/2006 @ 20:42
by aldweb

Anonymous

visitor
A good code is one that works
A better code usually comes with unexpected bugs

So your code is excellent

@+
aldweb
Write to aldweb   Post an answer  Top
active topic active   closed topic closed   Sticky Sticky   New New message   -   Correct Correct message   Close Close topic   Make sticky Make sticky
[]
Forum Topic  Forum 



 
^ Top ^