[Gambas-user] DATE function Gambas 3.8.4 (Distro)

Gianluigi bagonergi at gmail.com
Fri May 17 09:52:01 CEST 2019


Sorry, I would look at the answer 501

Gianluigi

Il giorno ven 17 mag 2019 alle ore 09:42 Gianluigi <bagonergi at gmail.com> ha
scritto:

> Take look here:
>
> https://askubuntu.com/questions/162391/how-do-i-fix-my-locale-issue/272892#272892
>
> Gianluigi
>
> Il giorno ven 17 mag 2019 alle ore 09:00 David Silverwood via User <
> user at lists.gambas-basic.org> ha scritto:
>
>> Thanks Gianluigi
>>
>> The following explains my problem, from your example. Thank you very much!
>>
>> gbx3: warning: cannot switch to language 'en_ZA
>> .UTF-8': No such file or directory. Did you ins
>> tall the corresponding locale packages?
>>
>> Tried it with EN_GB as well and again the same error. I suspect it may be
>> a distro error as gambas probably switches to en_US as default? en_ZA
>> should have installed when I originally installed Mint 18. Seems there is
>> no en_ZA language pack out there ??? Checked the distro. Ah well, back to
>> the drawing board.
>>
>> Thank you Charlie and Gianluigi, for your patience and your much valued
>> assistance. Really appreciate it!
>>
>> David
>>
>>
>> On Thursday, May 16, 2019, 11:35:07 PM GMT+2, Gianluigi <
>> bagonergi at gmail.com> wrote:
>>
>>
>> Try the attached project
>>
>> Regards
>> Gianluigi
>>
>> Il giorno gio 16 mag 2019 alle ore 19:45 Gianluigi <bagonergi at gmail.com>
>> ha scritto:
>>
>> I'm not talking about using dates like Strings (Cogier) but using dates
>> as Dates.
>> This was taught to me by Fabien Bodard (here) and Sotema in Italy.
>> If you always use the Date value for your calculations you will have no
>> problems.
>> Then when you need to show it to the user use Str or Format.
>>
>> Regards
>> Gianluigi
>>
>> Il giorno gio 16 mag 2019 alle ore 19:32 Gianluigi <bagonergi at gmail.com>
>> ha scritto:
>>
>> You can write the Date value like this:
>> hResult!usdat = hDate ' ReportTest
>> And you can read it like this:
>> Left(Str(hDate), 10) '(international)
>> Or
>> Format(hDate, "dd/mm/yyyy") '(Local)
>>
>> Regards
>> Gianluigi
>>
>> Il giorno gio 16 mag 2019 alle ore 18:48 David Silverwood via User <
>> user at lists.gambas-basic.org> ha scritto:
>>
>> and if I use today's date I get the following error...
>>
>> 'Error 21 in FExpenses.btnLoad_Click.143
>>
>> The following error has occurred:
>> Out of bounds'
>>
>> I think its stating that the month cannot be 16 and therefore out of
>> bounds because I do not get this error when I use say 2019-05-05/
>> 2019-09-12 etc. As I said, my textbox swops the month and day around.
>>
>> Please bear with me. I am currently learning Gambas.
>>
>>
>> On Thursday, May 16, 2019, 6:40:08 PM GMT+2, David Silverwood via User <
>> user at lists.gambas-basic.org> wrote:
>>
>>
>> To add
>>
>> if I do this, which I have also tried, it comes close but still swops the
>> month and day around...
>>
>>     If edtDate.Text Then
>>         sDate = Left$(edtDate.Text, 10)
>>         $Date = Split(sDate, "/")
>>         Debug sDate = $Date[2] & "-" & $Date[1] & "-" & $Date[0]
>>         edtDate.Text = sDate
>>     Endif
>>
>> Changing $Date[1] and $Date[0] around makes no difference whatsoever
>>
>> Regards
>>
>> David
>>
>> On Thursday, May 16, 2019, 6:31:07 PM GMT+2, David Silverwood via User <
>> user at lists.gambas-basic.org> wrote:
>>
>>
>> Hi Gianluigi
>>
>> Are you referring to this portion:
>>  Randomize
>>   $hConn.Begin()
>>   For i = 0 To $nRecords
>>     nCasual = Rand(0, 30)
>>     sName = aFirstName[nCasual]
>>     nCasual = Rand(0, 30)
>>     sSurname = aLastName[nCasual]
>>     y = Rand(1959, 2000)
>>     m = Rand(1, 12)
>>     d = Rand(1, 28)
>>     hDate = Date(y, m, d)
>>     hResult = $hConn.Create("tuser")
>>     hResult!usnam = sName
>>     hResult!ussur = sSurname
>>     hResult!usdat = hDate
>>     hResult.Update
>>   Next
>>
>> I actually found the code difficult to decipher but looking at it again I
>> assume you are referring to hDate = Date(y, m, d)?
>>
>>
>>
>> On Thursday, May 16, 2019, 6:25:09 PM GMT+2, Gianluigi <
>> bagonergi at gmail.com> wrote:
>>
>>
>> I had shown you the correct code you need to look at in Report1.
>>
>> Regards
>> Gianluigi
>>
>> Il giorno gio 16 mag 2019 alle ore 16:17 David Silverwood via User <
>> user at lists.gambas-basic.org> ha scritto:
>>
>> Ok, so I'm back with the same problem. It seems to me Gambas has a
>> template format for a date and trying to change it is impossible? As soon
>> as Gambas sees it as a date, it reformats my formatting back to the
>> incorrect format and renders all the code useless. Is this the way it is
>> supposed to be?
>>
>> I need my date formatted to sqlite format, eg, yyyy-mm-dd
>>
>> However, soon as I do that, gambas switches it to mm/dd/yyyy.
>>
>> My OS regional settings are correct. Using Mint 18.3 KDE and Gambas 3.13
>> (Thanks Charlie for the upgrade tip)
>>
>> The latter format is useless over here and inevitably gambas reads the
>> day and month wrong, by switching it... I've tried using Split and in a
>> debug /print statement I see that it does do exactly what I need, but once
>> the format hits the textbox, Gambas actually changes it back to mm/dd/yyyy.
>> How do I stop that? I tried DIM'ing the dates as Strings but Gambas seems
>> to read dates as dates even if they are dimensioned as strings? (which I
>> know they are 'special' strings of course).
>>
>> My sqlite3 database complains whenever I try and save the dates in
>> Gambas's preferred format.
>>
>> I know I am doing something wrong since no one else has this issue....
>> but what?
>>
>>
>>
>> On Tuesday, April 30, 2019, 11:05:06 AM GMT+2, David Silverwood via User <
>> user at lists.gambas-basic.org> wrote:
>>
>>
>> Thank you very much Charlie and Gianluigi. Those were pointers in the
>> right direction for me! I really appreciate your help. (Not to mention I
>> just learned a lot from both of your code too.)
>>
>>
>> ----[ Gambas mailing-list is hosted by https://www.hostsharing.net ]----
>>
>> ----[ Gambas mailing-list is hosted by https://www.hostsharing.net ]----
>>
>> ----[ Gambas mailing-list is hosted by https://www.hostsharing.net ]----
>>
>> ----[ Gambas mailing-list is hosted by https://www.hostsharing.net ]----
>>
>>
>> ----[ Gambas mailing-list is hosted by https://www.hostsharing.net ]----
>>
>> ----[ Gambas mailing-list is hosted by https://www.hostsharing.net ]----
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.gambas-basic.org/pipermail/user/attachments/20190517/407d38c4/attachment-0001.html>


More information about the User mailing list