[Gambas-user] Using dates in Gambas

Gianluigi bagonergi at gmail.com
Sat May 18 13:53:32 CEST 2019


Il giorno ven 17 mag 2019 alle ore 21:44 Benoît Minisini <g4mba5 at gmail.com>
ha scritto:

> Hi,
>
> As I notice that almost nobody suceeds in dealing with date & time
> correctly, I started to wrote a overview about that in the wiki.
>
> http://gambaswiki.org/wiki/doc/date
>
> Please feal free to comment and modify this page so that date & time
> management becomes as clear as possible.
>
> This is still a work in progress, and I especially need "how to" code
> example about dates.
>
> Regards,
>
> --
> Benoît Minisini
>


Hi Benoit,
probably could have inspired what I wrote here:

https://lists.gambas-basic.org/pipermail/user/2019-May/067200.html

In fact when I write:

"Left(Str(hDate), 10) '(international)"

I don't mean UTC but I mean "displaying the date in local format in all
countries"
And when I write:

"Format(hDate, "dd/mm/yyyy") '(Local)"

I mean "displaying the date in local format only in your country"

In my defense, I have attached a project that contains this code that
better explains what I wanted to say:
-------------------------------------------
' From a Sotema code
Public Sub Main()

  Dim hConn As Connection
  Dim hResult As Result
  Dim hTable As Table
  ' Activate the display of gb.db messages
  db.Debug = True
  ' Set the connection parameters
  With hConn = New Connection
    .Type = "sqlite"
    .Host = System.User.Home
    .Open
  End With
  ' if the db exists, delete it.
  ' this allows you to run the example several times
  If (hConn.Databases.Exist("exampledb")) Then
    hConn.Databases.Remove("exampledb")
    hConn.Databases.Add("exampledb")
  Endif
  hConn.Name = "exampledb"
  ' create the table
  hTable = hConn.Tables.Add("users")
  hTable.Fields.Add("id", db.Integer)
  hTable.Fields.Add("name", db.String, 80)
  hTable.Fields.Add("birth", db.Date)

  hTable.Update()
  ' add one record
  hConn.Begin()
  hResult = hConn.Create("users")
  hResult!id = 1
  hResult!name = "Gianluigi"
  hResult!birth = Date(1947, 4, 10)
  hResult.Update()
  hConn.Commit()
  ' retrieve the record
  hResult = hConn.Find("users") ' the same as  select * from users
  ' hResult = hConn.Exec("SELECT * FROM users")
  Print Left(Str(hResult["birth"]), 10)
  'Print Format(hResult["birth"], "dd/mm/yyyy")

End
------------------------------------------

and I had previously referred to ReportTest on the Software farm, that
treats dates the same way.

Regards
Gianluigi
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.gambas-basic.org/pipermail/user/attachments/20190518/55d6b760/attachment.html>


More information about the User mailing list