
Quote from joferar333 on May 1, 2022, 8:07 pm@asleycruz,@gaev,@vadim
ESPAÑOL
Hola! tengo un pequeño problema que no puedo resolver... si alguno sabe infinitamente agradecido
Yo tengo una base de datos sqlite donde en hay en una tabla dos campos uno FECHA y el otro HORA
definidos como DATETIME
Bien ahora la pregunta como puedo hacer para que al momento de ingresar datos de esta tabla estos campos se renellen automaticamente con la fecha y hora actual...
Es decir que no se deba ingresar manual que sea automatico como si fuera un campo AUTOINCREMENT...
ENGLISH
Hello! I have a small problem that I cannot solve ... if anyone knows infinitely
I have a SQLite database where in a table two fields one date and the other hour
defined as Datetime
Well now the question how can I ask that when you enter data from this table these fields are automatically reunits with the current date and time ...
That is to say that it should not be entered manual that is automatic as if it were a AUTOINCRENT
Thank you from now if anyone knows this.
Gracias desde ya si alguien conoce esto.
ESPAÑOL
Hola! tengo un pequeño problema que no puedo resolver... si alguno sabe infinitamente agradecido
Yo tengo una base de datos sqlite donde en hay en una tabla dos campos uno FECHA y el otro HORA
definidos como DATETIME
Bien ahora la pregunta como puedo hacer para que al momento de ingresar datos de esta tabla estos campos se renellen automaticamente con la fecha y hora actual...
Es decir que no se deba ingresar manual que sea automatico como si fuera un campo AUTOINCREMENT...
ENGLISH
Hello! I have a small problem that I cannot solve ... if anyone knows infinitely
I have a SQLite database where in a table two fields one date and the other hour
defined as Datetime
Well now the question how can I ask that when you enter data from this table these fields are automatically reunits with the current date and time ...
That is to say that it should not be entered manual that is automatic as if it were a AUTOINCRENT
Thank you from now if anyone knows this.
Gracias desde ya si alguien conoce esto.
Quote from Gaev on May 1, 2022, 11:51 pm@joferar333
One way to address this is to do it in the subroutine that you specify in your dbpOpenTable command ...
dbpOpenTable "database id" "table" "subroutine"
subroutine
The name of a subroutine from your publication's Subroutine Action. The subroutine specified here will be automatically executed whenever the table is updated or the current record number changes. This can be useful if you want to activity to take place whenever the reader displays a different record.
In this subroutine, you would check if these fields are empty or not; if they are empty, you would populate them as desired.
If this approach is something you want to pursue, I suggest that instead of DateTime, you define the field as BigInt ... and use the DateToNum command to store the desired information as a number (will make it easier to do math on this information) ... and use NumToDate for human consumption.
In fact, you won't need a second field because you can always extract the hour part from the stored information.
If you need the current Date+Time, look at the NeoBook Predefined Global Variables here ... https://winhelp.visualneo.com/PredefinedGlobalVariables.html
One way to address this is to do it in the subroutine that you specify in your dbpOpenTable command ...
dbpOpenTable "database id" "table" "subroutine"
subroutine
The name of a subroutine from your publication's Subroutine Action. The subroutine specified here will be automatically executed whenever the table is updated or the current record number changes. This can be useful if you want to activity to take place whenever the reader displays a different record.
In this subroutine, you would check if these fields are empty or not; if they are empty, you would populate them as desired.
If this approach is something you want to pursue, I suggest that instead of DateTime, you define the field as BigInt ... and use the DateToNum command to store the desired information as a number (will make it easier to do math on this information) ... and use NumToDate for human consumption.
In fact, you won't need a second field because you can always extract the hour part from the stored information.
If you need the current Date+Time, look at the NeoBook Predefined Global Variables here ... https://winhelp.visualneo.com/PredefinedGlobalVariables.html

Quote from joferar333 on May 2, 2022, 11:05 amGreetings @gaev
Thank you very much for your help, you could give me an example of the subroutine that you propose as you would do it ... infinitely addressed
Greetings @gaev
Thank you very much for your help, you could give me an example of the subroutine that you propose as you would do it ... infinitely addressed
Quote from Gaev on May 2, 2022, 4:15 pm@joferar333:
you could give me an example of the subroutine that you propose as you would do it
Before I can do that, I would need to know ...
- details of what these fields are being used for (record creation timestamp?, record update timestamp?, record viewed timestamp? etc.)
- how is this information accessed (by user ?, by you only ?, via the grid or in other ways ?)
- what is this information used for ?
In the mean time, you can learn more about this concept by ...
- adding a BigInt field (say DateNum) in your Table
- specifying a subroutine (say UpdateDateNum) in the dbpOpenTable command
- populating this field with the result of the DateToNum command that used the current date+time variables
- you might even consider adding another temporary text field (say DateText) that would store the (human readable) form of the current date+time- and observing the contents of this/these fields (not hidden for now)
Once you study these observations, you will be in a better position to tweak the subroutine to update these fields as per your needs.
@joferar333:
you could give me an example of the subroutine that you propose as you would do it
Before I can do that, I would need to know ...
- details of what these fields are being used for (record creation timestamp?, record update timestamp?, record viewed timestamp? etc.)
- how is this information accessed (by user ?, by you only ?, via the grid or in other ways ?)
- what is this information used for ?
In the mean time, you can learn more about this concept by ...
- adding a BigInt field (say DateNum) in your Table
- specifying a subroutine (say UpdateDateNum) in the dbpOpenTable command
- populating this field with the result of the DateToNum command that used the current date+time variables
- you might even consider adding another temporary text field (say DateText) that would store the (human readable) form of the current date+time
- and observing the contents of this/these fields (not hidden for now)
Once you study these observations, you will be in a better position to tweak the subroutine to update these fields as per your needs.

Quote from luishp on May 3, 2022, 5:41 pm@joferar333 creo que lo único que necesitas es una sentencia SQL que guarde la fecha actual:
https://stackoverflow.com/questions/15473325/inserting-current-date-and-time-in-sqlite-database
Saludos
@joferar333 creo que lo único que necesitas es una sentencia SQL que guarde la fecha actual:
https://stackoverflow.com/questions/15473325/inserting-current-date-and-time-in-sqlite-database
Saludos
Quote from Gaev on May 3, 2022, 8:36 pm@joferar333
I just realized that I made the mistake of assuming that you were talking about VisualNEOWin (not VisualNEOWeb) ... again ... please ignore my previous response(s) ... sorry.
I just realized that I made the mistake of assuming that you were talking about VisualNEOWin (not VisualNEOWeb) ... again ... please ignore my previous response(s) ... sorry.