Spécial ! |
Version mobile de l'aldweb Site m.aldweb.com Ni Français, ni Anglais ?Essayez donc l'un de ces drapeaux :
|
|
Météo / Spam / www |
Météo Lyon
aldweb contre le SPAM
|
|
|
|
|
|
|
- Forum - iziBasic
Warning: A non-numeric value encountered in /web5/aldweb/www/aldweb_com/www/thread.php on line 257
Sujet n° 994 |
Date Comparison |
le 24/11/2004 @ 22:22 par Mike Featherstone
|
Before I go and write an overly complex routine to do this (), does anyone know of a simple way of comparing a pair of iziBasic date strings and determining which is the earlier?
Thanks
Mike |
|
|
Warning: A non-numeric value encountered in /web5/aldweb/www/aldweb_com/www/thread.php on line 497
Réponse n° 1 -------- le 24/11/2004 @ 23:05 par aldweb
visiteur |
Hello Mike,
Nice to see you here
The easy way to compare two dates is to put them in this format: YYYYMMDD (Year Month Day) And if you want to compare time also: YYYYMMDDHHmmss (Year Month Day Hour Minute Second)
Example:
' get 24/11/2004 today D$=DATE$ ' transform to 20041124 A$=RIGHT$(D$,4)+MID$(D$,4,2)+LEFT$(D$,2)
Now, you can compare it with any other date formated the same way. Example:
B$="20041201" IF A$ < B$ THEN PRINT "Normal!" ELSE PRINT "Strange..." ENDIF
I hope my answer helps you
Cheers,
@+ aldweb |
|
|
Warning: A non-numeric value encountered in /web5/aldweb/www/aldweb_com/www/thread.php on line 497
Réponse n° 2 -------- le 24/11/2004 @ 23:56 par Mike Featherstone
visiteur |
Thanks.
I thought that was the format to use but string manipulation has never been my strong point and I couldn't think my way through it.
I would have ended up with a series of integer conversions - doing things the *very* long way round.
Having written a review that said 'I have a use for iziBasic', I thought it time to go and use it for real! |
|
|
Warning: A non-numeric value encountered in /web5/aldweb/www/aldweb_com/www/thread.php on line 497
Réponse n° 3 -------- le 25/11/2004 @ 22:07 par aldweb
visiteur |
I think that it is worth writing it for our friendly iziBasic fellows, Mike's great review is here: http://www.clieuk.co.uk/izibasic.shtml/
Thanks again Mike for this review. For me, this is a great reward to my work.
Cheers
@+ aldweb |
|
|
Warning: A non-numeric value encountered in /web5/aldweb/www/aldweb_com/www/thread.php on line 497
Réponse n° 4 -------- le 26/11/2004 @ 05:20 par Chuck
visiteur |
I tried similar date manipulation and the MID$ function kept returning a null string. I worked around it by using LEFT$ to cut off the string on the right and then RIGHT$ to pick off the part I needed. |
|
|
Warning: A non-numeric value encountered in /web5/aldweb/www/aldweb_com/www/thread.php on line 497
Réponse n° 5 -------- le 26/11/2004 @ 21:50 par Mike Featherstone
visiteur |
You're right - 24/04/2004 is returning 200424 rather than 20040424. MID$ seems to be malfunctioning. |
|
|
Warning: A non-numeric value encountered in /web5/aldweb/www/aldweb_com/www/thread.php on line 497
Réponse n° 6 -------- le 26/11/2004 @ 21:53 par aldweb
visiteur |
Thank you guys for the information. I will check for the bug and work on a fix.
Cheers
@+ aldweb |
|
|
Warning: A non-numeric value encountered in /web5/aldweb/www/aldweb_com/www/thread.php on line 497
Réponse n° 7 -------- le 26/11/2004 @ 23:19 par aldweb
visiteur |
MID$ is running fine. It is just a misunderstanding and my own initial mistake given in my sample source code when answering to Mike.
Structure is: MID$(var$,1st character,last character) and not MID$(var$,1st character,nb of characters)
So, my example becomes:
' get 24/11/2004 today D$=DATE$ ' transform to 20041124 A$=RIGHT$(D$,4)+MID$(D$,4,5)+LEFT$(D$,2)
Sorry for the mistake.
@+ aldweb |
|
|
Warning: A non-numeric value encountered in /web5/aldweb/www/aldweb_com/www/thread.php on line 497
Réponse n° 8 -------- le 26/11/2004 @ 23:32 par aldweb
visiteur |
Me again: I just checked and I can tell that last character is not BASIC's standard. I will change this to nb of characters in next release.
So, at the end, it's my mistake anyway
@+ aldweb |
|
|
Warning: A non-numeric value encountered in /web5/aldweb/www/aldweb_com/www/thread.php on line 497
Réponse n° 9 -------- le 26/11/2004 @ 23:38 par Mike Featherstone
visiteur |
Thanks for the help. I'll use the iziBasic standard for now! |
|
|
sujet actif
sujet clos
Important!
Nouveau message -
Rectifier message
Clôturer sujet
Remonter
|
|
|
|
|
|