Tuesday, November 20, 2012

MySQL Date and Time Type




 MySQL Date and Time Type: YEAR, TIME, DATE, DATETIME, TIMESTAMP

1.YEAR type
Both string and  number are fine.
As a 4-digit string in the range '1901' to '2155'.
As a 4-digit number in the range 1901 to 2155.
Note: Out of the range 1901 to 2155 converted to 0000

2. MySQL Time Type
HH:MM:SS
or
D HH:MM:SS
Here D is day converted  to hour  D+24*HH
Where HH hours, MM minutes, SS seconds

3.MySQL DATE Type
YYYY-MM-DD
Where YYYY years, MM  Months, DD days.

4. MySQL DATETIME Type
YYYY-MM-DD HH:MM:SS
Where YYYY years, MM  Months, DD days,
HH hours, MM minutes, SS seconds

5.MySQL DATESTAMP Type
YYYY-MM-DD HH:MM:SS
Where YYYY years, MM  Months, DD days,
HH hours, MM minutes, SS seconds

Similar to DATETIME,
 small difference, NULL and CURRENT_TIMESTAMP are current time

No comments:

Post a Comment