Manipulating date and time in database is an important task in any database driven application. MySQL is the most popular open source database deployed widely. Here are some tasks that you can perform on date and time using MySQL built in functions. Adding interval to a date DATE_ADD function allows adding/subtracting(using - sign) any interval to date/datetime. The usage of this function is as follows DATE_ADD(date,INTERVAL [expression] [unit] ) unit can be one of the following MICROSECOND,SECOND,MINUTE,HOUR,DAY,WEEK,MONTH,QUARTER,YEAR,SECOND_MICROSECOND,MINUTE_MICROSECOND,MINUTE_SECOND,HOUR_MICROSECOND,HOUR_SECOND,HOUR_MINUTE,DAY_MICROSECOND,DAY_SECOND,DAY_MINUTE,DAY_HOUR,YEAR_MONTH expression depends upon the unit. We will explore some units and respected expressions in this post. Note: All example queries use column name "column_dt" for a column of type datetime. Adding SECOND(s) to DATETIME Following query will add 1 second to the value of column_dt...
I document random stuff on this Blog. It can be a piece of code , my personal experience, a fun fact or anything else.