[Gambas-user] Date fun again - IsDate and CDate localisation?

Benoît Minisini g4mba5 at gmail.com
Thu Dec 24 19:24:47 CET 2020


Le 23/12/2020 à 13:42, KKing a écrit :
> So I'm in UK so expect dates in format dd/mm/yyyy using G 3.12.2 on 
> trying to validate a source feed file ...  I have the following.
> 
>> Dim strTest As String
>> Dim dteTest As Date
>> strTest = "14/01/2000 00:00:00"
>> If IsDate(strTest) Then
>>    dteTest = CDate(strTest)
>> Else
>>    dteTest = CDate(strTest)
>> Endif 
> 
> When I have strTest = "14/01/2020 00:00:00" it passes the "IsDate" test 
> but then fails on the CDate line with "type mismatch: wanted Date, got 
> string instead.
> 
> If I have strTest = "01/14/2020 00:00:00" it passes both ... why?
> 
> Is there some sort of localisation within Gambas I have to set?
> 
> K.
> 

It's normal. IsDate() checks for local date, whereas CDate() does not. 
It only uses "C" date, i.e. American ones.

Look at the documentation, it's written when a date function is for 
local dates or not.

Regards,


-- 
Benoît Minisini


More information about the User mailing list