MySQL DATE_ADD() and DATE_SUB()

In this tutorial, we will study the MySQL DATE_ADD() and DATE_SUB() functions. DATE_ADD() and DATE_SUB() are a variation of the ADDDATE() and SUBDATE() functions. The main difference is that DATE_ADD() and DATE_SUB() only have one syntax each, not two syntaxes like ADDDATE() and SUBDATE(). The DATE_ADD() function is used to add a date or time …

MySQL DATE_ADD() and DATE_SUB() Read More »

MySQL EXTRACT()

In this tutorial, we will study the MySQL EXTRACT() function. The EXTRACT() function is a combination of the date functions and others like WEEK() and QUARTER(), and the time functions and others like MICROSECOND(). The EXTRACT() function is used to extract a part from a date or datetime value. This part can be day, month, …

MySQL EXTRACT() Read More »

MySQL GREATEST() and LEAST()

In this tutorial, we will study the MySQL GREATEST() and LEAST() functions. Suppose you have a ‘Triangles’ table that stores the length of the three sides of each triangle in three separate columns. You have been tasked to find the longest and the shortest side of each triangle. How do you do this? Normally, you …

MySQL GREATEST() and LEAST() Read More »

MySQL ADDTIME() Function

In this tutorial, we will study the MySQL ADDTIME() function. Suppose you have a table which contains the names of shops and their opening time. Now suppose during winters, these shops decide to open an hour late. You have been tasked with adding an hour to all the time values. This situation calls for the …

MySQL ADDTIME() Function Read More »