![image](/static/img/ProfessionslsCommunity.png)
Problem :
We would like to get 12 hours ago datetime in MySQL database. So we need to execute query to solve this.
Solution :
Write bellow query to get12 hours ago datetime -
SELECT NOW(), DATE_SUB(NOW(), INTERVAL '12' HOUR) AS date_time
Output :
![](https://devs3.pro/media/blog_image/image_7M9rDwc.png)
Discussions :
To get 12 hours ago datetime you need to substract 12 hours from current time. You need to use NOW() to get current date time. After then you need to substract 12 hours from current time using DATE_SUB() function. Here you need to substract 12 hours as DATE_SUB(NOW(), INTERVAL 12 Hour).