DateTime is the most commonly used date type in SQL.Storage size: 8 bytes;Date range: 1753-01-01 to 9999-12-31;Accuracy: 3.33 ms;Common Date function getdate () Gets the current date of the systemSelect GETDATE ()DatePart (Part,dtvalue) Gets the
Interviewed a company yesterday, asked to get the last order of the month on the machine topic. Using the date of the selective query, came back on the Iteye found this article.Original: http://new-fighter.iteye.com/blog/1758723① First day of the
No nonsense.CodeThe comment is very detailed. It is certainly okay to understand it!
Declare @ date datetimeSet @ date = getdate ()-The previous day, the previous day of the given dateSelect dateadd (day,-1, @ date) as 'previous Day'-The next day,
SQL Query day, week, month record--Day of enquiry:[SQL] View plaincopyprint?SELECT * FROM info where DateDiff (dd,datetime,getdate ()) =0--Query within 24 hours:[SQL] View plaincopyprint?SELECT * FROM info where DateDiff (hh,datetime,getdate ())
DECLARE @ DateDATETIMESET @ DateGETDATE () -- previous DAY, previous DAY of given Date SELECTDATEADD (DAY,-1, @ Date) AS previous DAY -- next DAY, next DAY of given Date SELECTDATEADD (DAY, 1, @ Date) AS the next day GO -- the beginning of the month,
One, character conversion function1. ASCII ()Returns the ASCII value of the leftmost character of a character expression. In the ASCII () function, a string of pure numbers is not "enclosed", but a string with other characters must be used in '
Recently in the writing of a project, using the time of comparison and time of the addition and subtraction, here briefly, I was just contact with the database soon, if there are said improper place to hope that you forgive, correct meA comparison
Learn from:http://bjtdeyx.iteye.com/blog/1447300The most common statements for SQL date queries -- query data on the first anniversary of the date of the day select * from shoporder where datediff (Week,ordtime,getdate () - 1 ) = 0 --
The number of SQL statements on the first and last day of the month is taken online, either through character interception, or through functions, individuals or rather by using built-in functions to handle,But look at the use of the online function
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.