aldweb

Fermer I. aldweb

Fermer II. Gratuitiels PC

Fermer III. Gratuitiels Palm

Fermer IV. Partagiciels Palm

Fermer V. iziBasic Palm

Fermer VI. Connaissance Palm

Fermer VII. Ordinateur Poche

Fermer VIII. miniPortail

Spécial !



Version mobile
de l'aldweb Site

m.aldweb.com


Ni Français, ni Anglais ?

Essayez donc l'un de ces drapeaux :
[de] [es] [it] [pt]
Recherche




Météo / Spam / www

Météo Lyon


aldweb contre le SPAM


Newsletter
Pour avoir des nouvelles de ce site, inscrivez-vous à notre Newsletter.
S'abonner
Se désabonner
298 Abonnés
Sites web de la famille

Webmaster - Infos
News Amis
Visites

   visiteurs

   visiteurs en ligne

Sondage
Comment trouve-tu le nouvel habillage de l'aldweb Site ?
 
Superbe !
Joli
Moyen
Moche...
Résultats
forum.gifForum - iziBasic - Sujet n°1356

Forum - Forum
iziBasic - iziBasic


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

actif  Sujet n° 1356  DateDiff Function

le 01/02/2006 @ 11:35
par André

Anonyme



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?
Ecrire à André   Poster une réponse  Haut

[]   


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

Anonyme

visiteur
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
Ecrire à Nevin   Poster une réponse  Haut

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

Anonyme

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

Cheers,
aldweb
Ecrire à aldweb   Poster une réponse  Haut

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

Anonyme

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

Ecrire à Khertan   Poster une réponse  Haut

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

Anonyme

visiteur
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 :)
Ecrire à Khertan   Poster une réponse  Haut

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

Anonyme

visiteur
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
Ecrire à Nevin   Poster une réponse  Haut

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

Anonyme

visiteur
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
Ecrire à aldweb   Poster une réponse  Haut

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

Anonyme

visiteur
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.
Ecrire à Nevin   Poster une réponse  Haut

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

Anonyme

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

So your code is excellent

@+
aldweb
Ecrire à aldweb   Poster une réponse  Haut
actif sujet actif   clos sujet clos   Important! Important!   Nouveau Nouveau message   -   Rectifier Rectifier message   Clôturer Clôturer sujet   Remonter Remonter
[]
Catégories de discussion  Forum 



 
^ Haut ^