insertar fecha / add date to database - Forum

Forum Navigation
You need to log in to create posts and topics.

insertar fecha / add date to database

@luishp buen dia por suerte despues de mucho penar todo el manejo de los datos en la base de tados funciona perfecto.

solo tengo un pequeño drama y seguramente debe ser un error de mi parte, tengo un campo que es fecha, que debe insertar el valor de la variable fecha

Yo la variable la defini asi .

Setvar [fecha] [([NAB.DayNum]/[NAB.MonthNum]/[NAB.Year])]

Pero cuando verifico en la base los datos insertados estan todos los campos menos fecha ahi me pone  undefinet

Seguramente estoy definiendo mal la variable puede ser?

Mil gracias y buen fin de semana

Cordial saludo

 

ENGLISH

@roccocogliano

I have a field that is date, which should insert the value of the date variable

I defined the variable like this.

Setvar [date] [([NAB.DayNum]/[NAB.MonthNum]/[NAB.Year])]

But when I check the inserted data in the database, there are all the fields except the date, there it says undefinet

Surely I am defining the variable wrong maybe?

Thank you very much and have a good weekend

Best regard

Hi @joferar333,

this line is wrong ---> Setvar [date] [([NAB.DayNum]/[NAB.MonthNum]/[NAB.Year])]

you are nesting the square brackets

try with this ---> setvar [date] "[NAB.DayNum]/[NAB.MonthNum]/[NAB.Year]"

and don't forget the quotation marks otherwise you will get the division of the various numbers retrieved from the special variables

@luishp,@roccocogliano, thanks

Yes now it does but look at how it inserts the date..
0.0009886307464162135
I have no idea how to make it take the content that I put into it...

did you forget the quotation marks?

@luishp, @roccocogliano You are right I had forgotten the quotes but even so having added them insert the data but wrong 0.0009886307464162135 

that number is just the division of day, month and year

can you share the application?

Otherwise I don't understand

@roccocogliano Put together a small example where the base is and the app must insert the current date in the date field...

Uploaded files:
  • You need to login to have access to uploads.

@joferar333

Check out the attached working example which inserts the date correctly.
Your example didn't have the config.php, so I can't know how you had written the insert query.
Also in the 'added' routine you used a parameter named '[date]' but then you used a variable named '[data]' in the code.
In db 'test.db' you had only field 'fecha' and no other fields, not even a primary key.

Uploaded files:
  • You need to login to have access to uploads.

I advise you to review all the examples (even videos, e.g. https://www.youtube.com/watch?v=u7IenKUhKAQ ) on databases.
They are very useful and well made.

Greetings
Rocco

@joferar, tienes problemas de sintaxis aquí:

Esto que has puesto está mal y ni siquiera se ejecutará (te sobran corchetes):

Setvar [date] [([NAB.DayNum]/[NAB.MonthNum]/[NAB.Year])]

Esto otro creará una variable numérica ejecutando la división matemática de las tres cifras que le das:

Setvar [date] [NAB.DayNum]/[NAB.MonthNum]/[NAB.Year]

Esto sería lo correcto ya que crea una variable de cadena de texto concatenando los tres números separados por una barra:

Setvar [date] "[NAB.DayNum]/[NAB.MonthNum]/[NAB.Year]"

Saludos.

roccocogliano has reacted to this post.
roccocogliano