Difference between DateDiff functions in SQL and Access

Source: Internet
Author: User
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 ~~~~~

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.