[Gambas-user] Convertion bug or problemm undestood !!!

Benoit Minisini gambas at ...2...
Tue Nov 11 14:25:39 CET 2003


Le Mardi 11 Novembre 2003 08:12, Olivier Coquet a écrit :
> i've understood a problem with conversion date
>
> folow me
>
> in mysql database date is stored with this format:
>
> mm/dd/yy
>
> when i get a date value from db to put it in a text area form field a
> convert it with cdate
> cdate(madate) => dd/mm/yy
>
> when i modify it and want to store it in my data base i try to reconvert it
> as good format with Format$
>
> Format$(madate,"mm/dd/yy")
>
> but it does not work because madate is note a valid format for Format$
> Function.
>
> Format$ is not reversing
>
> I think it's iportant to implement this in the future 0.72 version of
> gambas.
>
> regards
> Olivier
>
>

If you read a date from a MySQL database, you get a Date value. You don't know 
what format use mysql use to store its date values internally.

If you want to put a date into a text field, just do:

  MyTextBox.Text = Str(MyDate)

You should not use your own format, but let the localization system do it for 
you. (See the Format$() documentation)

If you want to put the text field in the database, just do:

  MyVariant = Val(MyTextBox.Text)
  IF IsDate(MyVariant) THEN MyDate = MyVariant

You must not use CDate() and CStr() functions, because these functions do not 
use the localization settings !

Be careful ! This is the contrary in VB, and it's more coherent in Gambas, 
which DO NOT CLONE Visual Basic when Visual Basic are a bit stupid. Read the 
documentation carefully !

Regards,


-- 
Benoit Minisini
mailto:gambas at ...1...





More information about the User mailing list