I want to make a search today and use the time comparison function!
In the past, it was usually a direct comparison time, and the query statement was not highly efficient ~~~
Later, I used the DateDiff function and found some problems during debugging. I would like to summarize a few of them and share them with you. ^_^
1. Database problems. The Access and SQL read time functions are different. Now () can only be used in Access. In SQL, The GetDate () function can only be used to obtain the system time, other functions, such as Time (), should be noted during debugging.
2. It is DateDiff ('D', Time1, Time2). At the beginning, I found that how to debug this function is too much to pass the ACCESS special SQL statements of the database, SQL statements that can be used in ACCESS cannot be used ~~~
However, I went to the Internet to search and found that there was a real difference ~~~
Specifically:
Access: DateDiff ('D', Time1, Time2)
SQL: DateDiff (d, Time1, Time2)
Note that quotation marks are not required in SQL.
The following are SQL query statements written by the DateDiff function.
Select PigID, PigName, RingNum, Sex, PigOwner, PostDate, Passed FROM HZ_Pig Where DateDiff (m, 'shoottime', PostDate) <= 0
The specific function is not mentioned. Many people on earth know it!
Hey, hope you can help me ~~~~~