SQL Time Comparison

Source: Internet
Author: User

Data fields varchar Type, format: 20110228 151010
To make time comparisons, search for a time in a range
SELECT * FROM table where '

20120102 ' < ' time ' < ' 20120109 '

SELECT * from ' table ' WHERE replace (' otime ', ' ', ') between ' 20120102 ' and ' 20120105 '

VARCHAR (n): variable-length character data type, stored for a maximum length of 8,000 characters
Variable-length, non-Unicode character data with a length of n bytes. n must be a numeric value between 1 and 8,000.
Storage size is the actual length of bytes of input data, not n bytes. The input data character length can be zero. The synonym for varchar in SQL-92 is char varying or character varying. Note If n is not specified in a data definition or variable declaration statement, the default length is 1. If n is not specified using the CAST function, the default length is 30.
If you want the data value in the column to be significantly different in size, use varchar.

For example, SQL Server2000, my software needs to be date 2009-10-19 10:16:54 save, then I tested, set the property of the field to varchar, the advantage is that it can set the length, when it is connected with other clients when the compatibility is good AH.

SQL Time Comparison

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.