Comparison of access and sqlserver time and date and other SQL statements

Source: Internet
Author: User
1. datediff:

1.1 calculate the date difference:
1. Access: datediff ('D', fixdate, getdate ())
2. sqlserver: datediff (day, fixdate, getdate ())
Access instance: Select * from table where datediff ('D', fixdate, getdate ()> 0
Sqlserver instance: Select * from table where datediff (day, fixdate, getdate ()> 0

1.2 calculate the time difference:
1. Access: datediff ('h', fixdate, getdate ())
2. sqlserver: datediff (hour, '2017-12-10 ', getdate ())
Access instance: Select datediff ('h', HMD, getdate ())
Sqlserver instance: Select datediff (hour, '2017-12-10 ', getdate ())

1.3 calculate the month difference:
1. Access: datediff ('M', fixdate, getdate ())
2. sqlserver: datediff (month, '2017-12-10 ', getdate ())
Access instance: Select datediff ('M', HMD, getdate ())
Sqlserver instance: Select datediff (month, '2017-12-10 ', getdate ())
----------------------------------------------------------------------------

2. Date Variables
1. Access: # "& Data &"#
2. sqlserver: '"& Data &"'
Access instance: Select * from table where data = # "& Data &"#
Sqlserver instance: Select * from table where data = '"& Data &"'
----------------------------------------------------------------------------

3. Is it true?
1. Access: not finished
2. sqlserver: finished = 0
Access instance: Select * from table where not finished
Sqlserver instance: Select * from table where finished = 0
----------------------------------------------------------------------------

4. Calculate the remainder

1. Access: A mod B = 100
2. sqlserver: A % B = 100
Access instance: select a mod B = 100 from table where not finished
Sqlserver instance: select a % B = 100 from table where finished = 0
----------------------------------------------------------------------------

5. Obtain the date of the current day
1. Access: Now ()
2. sqlserver: getdate ()
Access instance: select now ()
Sqlserver instance: Select getdate ()

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.