MSSQL Server Common date functions
Your program may need to determine the first or last day of one months. Most of you probably know how to split dates (year, month, day, etc.), and then just use the split year, month, day, etc in several functions
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 ())
1. Click Cancel to delete the corresponding row.2. In the Add row function, add a variable to make it equal to the newly added row each time. In the rowUpdate event, set the row to edit if it is the newly added row.3. In the rowedit event, if
UF Maintenance Common SQL Statement Script (Classic) (top) UF maintenance Staff Common SQL script--Query the UF version number use Ufsystem go select * from Ua_version go------------------------------ -------------------------------------View System
CONVERT (Data_type,expression[,style])CONVERT (varchar (10), field name, conversion format)
DescriptionThis style is generally in the type of time (datetime,smalldatetime) and String type (Nchar,nvarchar,char,varchar)When they are converted to each
Generally, you need to obtain the current date and calculate some other dates. For example, your program may need to determine the first or last day of a month. Most of you probably know how to divide the date (year, month, day, etc.), and then
SQL queries this week's questions this month
--- Calculate the number of days for differenceSelect datediff (day, '2017-01-01 ', getdate ())-- 1. The first day of a monthSelect dateadd (mm, DATEDIFF (mm, 0, getdate (), 0)-- 2. Monday of the
This week: SELECT * FROM table where DATEDIFF (Week,c_calltime,getdate ()) =0--c_calltime as Date fieldThis month: SELECT * FROM table where DATEDIFF (Month,c_calltime,getdate ()) =0--c_calltime as Date fieldThis season: SELECT * from table where
This note sorts out the video lecture "SQL from getting started to improving" trained by Yang zhongke in Chuanzhi podcast. net. Video related links: http://www.rupeng.com/forum/tj-16325-2477.html
Database concepts
1. What is an index? What are the
--1. Current system date, timeSelect GETDATE ()--2015-01-06 09:27:27.277 --2. Time operation DateAdd Returns a new datetime value based on adding a period of time to a specified dateDATEADD (Datepart,number,date)Note:Datepart:year (yy, yyyy) |
Three days select * from T_news where DateDiff (Day,addtime,getdate ()) = 0a week select * from T_news WHERE (DATEPART (wk, addtime) = DATEPART (wk, GETDATE ())) and (DATEPART (yy, addtime) = DATEPART ( YY, GETDATE ()))Note: You cannot use the
SQL Server Date and Time Processing set
When the convert date conversion format is 20 or 120, the resulting string does not contain milliseconds.For example, select convert (varchar (23), getdate (), 120 or 20)21:46:43
When the date conversion
DateDiff (Week,zy_time,getdate ()) =0//query this weekDateDiff (Month,zy_time,getdate ()) =0//enquire this monthThis season: SELECT * from table where DATEDIFF (Qq,c_calltime,getdate ()) =0First half year 1-6, after half year 7-12:select * from
Reference:http://www.cnblogs.com/coconut_zhang/archive/2009/02/02/1382598.htmlHttp://blog.itpub.net/14766526/viewspace-1156100/Select GETDATE () as ' current date ',Datename (Year,getdate ()) as ' year ',Datename (Month,getdate ()) as ' month
Note: Sunday is the first day of the week, not the last day of the week () minus one day, such as dateadd (day,-1, getDate () This week: select * fromtablewheredatediff (week, C_CALLTIME, getdat
Note: Sunday is the first day of the week, not the
Data that is often stored in the datetime format of SQL Server is sometimes, minute, second, and so on. However, when the page is read, the notification only requires year, month, and day, You can use the following method to read data from the
SQL Server date calculation
SQL Server date calculation
SQL Server date calculation
Generally, you need to obtain the current date and calculate some other dates. For example, your program may need to determine the first or last day of a month.
Select GETDATE() as 'Current Date', Datename( Year,GetDate()) as 'years', Datename(Month,GetDate()) as 'Month', Datename( Day,GetDate()) as 'Day', Datename(DW,GetDate()) as 'Week', Datename(Week,GetDate()) as 'Week number',
Select GETDATE () as ' current date ',Datename (Year,getdate ()) as ' year ',Datename (Month,getdate ()) as ' month ',Datename (Day,getdate ()) as ' Day ',Datename (Dw,getdate ()) as ' Week ',Datename (Week,getdate ()) as ' Week number ',Datename
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.