How to compare the two date sizes in a database table

Source: Internet
Author: User
How to compare the two date sizes in a database table one table in the database has two dates, one is start, the other is end, and how to compare the sizes of the two, in addition, if the end date is before the start date, a message will be prompted, and the cursor will be placed in the date box and re-input !! Please answer !, Generally, you can use & lt; or & gt; to compare the date and datetime types. The author describes how to compare the two date sizes in the database table.
In my database, there are two dates in a table, one is start and the other is end. how can I compare the sizes of the two, and the end date will prompt information before the start date, place the cursor in the date box and try again !! Please answer!

------ Solution --------------------
Generally, you can use the <or> number to compare the time of the date and datetime types.
------ Solution --------------------
The owner's description is incorrect.

The frontend user enters two dates. if start> end is detected by js, the prompt message is displayed immediately. if the user spoofs the form request to submit start> end, the php end should also detect start <= end again when processing the form. In addition, if you want to perform better interaction, you still need to submit the form via ajax. if you do not need to update the form, php will verify the start and end. if not, an invalid ajax prompt will be returned, otherwise, insert the database and return the ajax success prompt.
------ Solution --------------------
Discussion
In my database, there are two dates in a table, one is start and the other is end. how can I compare the sizes of the two, and the end date will prompt information before the start date, place the cursor in the date box and try again !! Please answer!

------ Solution --------------------
Discussion

Reference in a format similar to 2004-10-10:

Reference:
In my database, there are two dates in a table, one is start and the other is end. how can I compare the sizes of the two, and the end date will prompt information before the start date, place the cursor in the date box and try again !! Please answer!


What type of date is your date?
If it is a string, a conversion is required.
If it is a timestamp, you can directly compare
Finally, move the cursor ......

------ Solution --------------------
It cannot be converted into a timestamp. Haha

SELECT UNIX_TIMESTAMP ('2017-10-04 22:23:00 ');
875996580

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.