[英]How to find the nearest 25th or 10th day for a given date and adds it to the database
[英]How to check if a date is before 10th of that month in mysql?
我有一個日期列:
Report_Received
8/7/2019 11:39
6/18/2019 10:25
我想檢查日期是否在該年那個月的10號之前。 如果是,則需要在新列(Complaince_Reporting)下說“真”,否則為“假”。
有什么辦法嗎?
您可以使用DAY
函數獲取月中的某天,但是首先,因為您沒有使用MySQL Datetime列或有效的MySQL日期格式,因此需要使用STR_TO_DATE
轉換日期。 像這樣:
SELECT ...,
DAY(STR_TO_DATE(Report_received, '%c/%e/%Y')) < 10 AS Compliance_Reporting
FROM yourtable
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.