All pastes #676341 Raw Edit

Something

public text v1 · immutable
#676341 ·published 2007-08-30 23:35 UTC
rendered paste body
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 715
Server version: 5.0.32-Debian_7etch1-log Debian etch distribution

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

mysql>  select TIMESTAMPDIFF(DAY,'1970-01-01',now());
+---------------------------------------+
| TIMESTAMPDIFF(DAY,'1970-01-01',now()) |
+---------------------------------------+
|                                 13755 |
+---------------------------------------+
1 row in set (0.00 sec)

mysql>  select TIMESTAMPDIFF(month,'1970-01-01',now());
+-----------------------------------------+
| TIMESTAMPDIFF(month,'1970-01-01',now()) |
+-----------------------------------------+
|                                     451 |
+-----------------------------------------+
1 row in set (0.00 sec)

mysql>  select TIMESTAMPDIFF(year,'1970-01-01',now());
+----------------------------------------+
| TIMESTAMPDIFF(year,'1970-01-01',now()) |
+----------------------------------------+
|                                     37 |
+----------------------------------------+
1 row in set (0.00 sec)

mysql> help date and time functions
You asked for help about help category: "Date and Time Functions"
For more information, type 'help <item>', where <item> is one of the following
topics:
   ADDDATE
   ADDTIME
   CONVERT_TZ
   CURDATE
   CURRENT_DATE
   CURRENT_TIME
   CURRENT_TIMESTAMP
   CURTIME
   DATE FUNCTION
   DATEDIFF
   DATE_ADD
   DATE_FORMAT
   DATE_SUB
   DAY
   DAYNAME
   DAYOFMONTH
   DAYOFWEEK
   DAYOFYEAR
   EXTRACT
   FROM_DAYS
   FROM_UNIXTIME
   GET_FORMAT
   HOUR
   LAST_DAY
   LOCALTIME
   LOCALTIMESTAMP
   MAKEDATE
   MAKETIME
   MICROSECOND
   MINUTE
   MONTH
   MONTHNAME
   NOW
   PERIOD_ADD
   PERIOD_DIFF
   QUARTER
   SECOND
   SEC_TO_TIME
   STR_TO_DATE
   SUBDATE
   SUBTIME
   SYSDATE
   TIME FUNCTION
   TIMEDIFF
   TIMESTAMP FUNCTION
   TIMESTAMPADD
   TIMESTAMPDIFF
   TIME_FORMAT
   TIME_TO_SEC
   TO_DAYS
   UNIX_TIMESTAMP
   UTC_DATE
   UTC_TIME
   UTC_TIMESTAMP
   WEEK
   WEEKDAY
   WEEKOFYEAR
   YEAR
   YEARWEEK

mysql> help STR_TO_DATE
Name: 'STR_TO_DATE'
Description:
Syntax:
STR_TO_DATE(str,format)

This is the inverse of the DATE_FORMAT() function. It takes a string
str and a format string format. STR_TO_DATE() returns a DATETIME value
if the format string contains both date and time parts, or a DATE or
TIME value if the string contains only date or time parts.

The date, time, or datetime values contained in str should be given in
the format indicated by format. For the specifiers that can be used in
format, see the DATE_FORMAT() function description. If str contains an
illegal date, time, or datetime value, STR_TO_DATE() returns NULL.
Starting from MySQL 5.0.3, an illegal value also produces a warning.

mysql>