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 some of the issues with mongo_^ 1 and the database. The Access and SQL read time functions are different. Now () only allow

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 some of the issues with mongo_^ 1 and the database. The Access and SQL read time functions are different. Now () only allow

I want to make a search today and use time comparisonFunction!

In the past, it was usually a direct comparison time, and the query statement was not highly efficient ~~~

Later, DateDiff was used.FunctionI found some problems during debugging. I would like to summarize some of them and share them with you. ^_^

1. Database problems, Access and SQL read timeFunctionDifferent, Now () can only be used in Access, and GetDate () can only be used in SQL ()FunctionTo obtain the system time.FunctionFor example, Time (). You should pay attention to it during debugging.

2. It is DateDiff ('D', Time1, Time2). At the beginning, I found thisFunctionHow can I debug SQL statements that fail frequently? Why can't I use SQL statements that can be used in ACCESS ~~~

But then I went to the Internet to search and found thatDifferences~~~

Specifically:

Access: DateDiff ('D', Time1, Time2)

SQL: DateDiff (d, Time1, Time2)

Note that quotation marks are not required in SQL.

The following is your own DateDiff.FunctionSQL query statements written

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.