Php SQL server operations tips on time and date reading _ PHP Tutorial

Source: Internet
Author: User
Php SQL Server provides a small insight on time and date reading. Last Friday, I wanted to build a php program and connect the mysql database to the SQL Server database. I used to use mysql, but I was not very familiar with SQL Server. Nothing else. as of last Friday, we had to make a php connection to the mysql database and the SQL Server database at the same time.
I have been using mysql for a long time and I am not very familiar with sqlserver. None of them, at least mysql and sqlserver, are relatives.
When performing a conditional query. An error occurred.
First, the query time is in this format.
11 30 2009 10:20:20 AM
I open sqlserver database to view table data
It is 10:20:20. 233
Later, I checked it and it seems that sqlserver has a format problem, but the output was. there is no way. I can only convert it after querying the data.
In mysql
For example, if you want to query data in the period from
Select * from table where time> '2017-11-01 'and time <'2017-11-30 ';
I drew a tiger, but I don't know where I am going,
I think my is indeed not as good as 11 30 2009 10:20:20 AM or 10:20:20. 233, at least not comparable
So I switched my to 11 01 2009 00:00:00 AM and 00:00:00. 000
Another one is worse. An error occurs in. Isn't that uncomfortable!
So it's not easy to find me for a day. I can't influence my image because of this small problem. I woke up early today,
I found the convertime conversion function convert yesterday. There are many convert types, that is, I don't know whether I am stupid or I am stupid.
No way. you can only replace it. first, convert 2009-11-01 to 20091101, then convert 11 30 2009 10:20:20 AM or 2009-11-30 10:20:20. 233 to 20091130, and then compare,
Let alone, it's really a result.
Select * from table where convert (varchar (10), date_time, 112 )! <$ Begin_date and convert (varchar (10), date_time, 112)!> $ End_date
(! <And!> I almost caught up with me)

At the same time, I have been using mysql for the connection between the mysql database and the sqlserver Database. I am not very familiar with sqlserver, so I feel the stones crossing the river. Nothing else...

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.