In what format is the date entered in MySQL?

0

In class we work with java and we have started with the databases, we use the MySQL Driver Library JDBD (I do not know if this influences anything, forgive my ignorance) and I would like to know when entering a date in a table , in what order the day, month and year are entered. As I understand it would be 'yyyy / mm / dd'. I hope someone can confirm or correct me, greetings.

    
asked by Sergio Encina 18.01.2018 в 10:12
source

1 answer

0

Generally the format is: '' YYYY-MM-DD ''

But according to the MySQL manual itself:

  

Date and time values can be represented in various formats, such as text with quotes or as numbers, depending on the exact type of the value and other factors. For example, in contexts in which MySQL expects a date, it interprets '2015-07-21', '20150721' and 20150721 as dates.

For date and time the format is as follows: 'YYYY-MM-DD HH: MM: SS' or equally 'YY-MM-DD HH: MM: SS'

In case you need to insert the date / date and current time of some field of your database you can do it with now ():

Example:

  

INSERT INTO users (alias_user, counter_user, date_register_user)   VALUES ('peluso', 'peluso3000', NOW ())

References:

answered by 19.01.2018 в 03:16