Date Time Data Type

My SQL comes with the following data types for storing a date or a date/time value in the database.


Date time data type with pre-defined functions

  • CURDATE ( ) : Give current date ( YYYY-MM-DD )
  • CURTIME ( ) : Give current time ( HH:MI:SS )
  • NOW ( ) : Give both current date and current time ( YYYY-MM-DD HH:MML:SS )

 NOTE : This all the above data types are used in the table.

Syntax -

The syntax is the same as creating a table but where we declare date & time type like varchar, int etc. there we need to write the above data type.

when we insert data into this data type we must follow the above formate of date, time and DateTime.

NOTE: Inserted data into this data type must be inside ( ' ' ).

sql date time data type

sql date time data type