[Gambas-user] How to check if it is a valid date?
Benoit Minisini
gambas at ...1...
Fri Aug 20 15:01:52 CEST 2004
On Friday 20 August 2004 14:36, Hans-Martin Bundeshund wrote:
> Salute Benoit,
>
> sorry to say, but I tested it with the yaer at last
> before your reply. I got the same results.
>
> Here is the source-snippet:
>
>
> act_day = 20
> act_month = 8
> act_year = 2004
>
> IF IsDate(Format$(act_day,"00") & "/" &
> Format$(act_month, "00") & "/" &
> Format$(act_year,"0000")) THEN
> datum = Date(act_year,act_monat,act_day)
> ELSE
> message.Info("Date WRONG: " & act_day & "." &
> act_month & "." & act_year)
> ENDIF
>
>
> Result: Date WRONG: 20.8.2004
>
>
> What I am doing wrong?
>
> regards,
>
> HM
>
I told you rubbish...
IsDate() does not test if something can be converted to a date, but test if
the type of a value is a date.
To check if something can be converted to a date, do the conversion, and check
if you got an error. It is the better way.
TRY datum = Date(act_year, act_month, act_day)
IF Error THEN
Message(...)
ENDIF
Regards,
--
Benoit Minisini
mailto:gambas at ...1...
More information about the User
mailing list