Weather / Spam / www |
Lyon Weather
aldweb against spam
|
|
|
|
|
|
|
- Forum - iziBasic
Warning: A non-numeric value encountered in /web5/aldweb/www/aldweb_com/www/thread.php on line 257
Topic # 994 |
Date Comparison |
24/11/2004 @ 22:22 by 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
Answer nฐ 1 -------- 24/11/2004 @ 23:05 by aldweb
visitor |
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
Answer nฐ 2 -------- 24/11/2004 @ 23:56 by Mike Featherstone
visitor |
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
Answer nฐ 3 -------- 25/11/2004 @ 22:07 by aldweb
visitor |
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
Answer nฐ 4 -------- 26/11/2004 @ 05:20 by Chuck
visitor |
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
Answer nฐ 5 -------- 26/11/2004 @ 21:50 by Mike Featherstone
visitor |
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
Answer nฐ 6 -------- 26/11/2004 @ 21:53 by aldweb
visitor |
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
Answer nฐ 7 -------- 26/11/2004 @ 23:19 by aldweb
visitor |
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
Answer nฐ 8 -------- 26/11/2004 @ 23:32 by aldweb
visitor |
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
Answer nฐ 9 -------- 26/11/2004 @ 23:38 by Mike Featherstone
visitor |
Thanks for the help. I'll use the iziBasic standard for now! |
|
|
topic active
topic closed
Sticky
New message -
Correct message
Close topic
Make sticky
|
|
|
|
|
|