--------------------------------------------
-- Title: the commonly used date calculation method in reports
-- Author: htl258 (Tony)
-- Date:-09-21
-- Reprinted please keep this
How to obtain the first and last days of a month for SQL statements?
Select cast (left ('20140901', 4) + '-' + substring ('20160901', 5, Len ('20160901 ')) + '-' + '01') as datetime)-- Day 1Select dateadd (day,-1, dateadd (month, 1, cast (left ('00
DECLARE @date datetime;
Set @date = GETDATE ()
--the number of days between the first day of the month and the first of the following month
Select DateDiff (Day,dateadd (Month,datediff (month,0, @date), 0), DateAdd (Month,1+datediff (month,0,
Calculating the time difference in PHP is sometimes a hassle! But as long as you have the use of the date and the function, that's a simple thing to do.
Recently, when I studied my favorite scarf, I counted the number of days in love, which
1. to automatically add fields, you must rewrite them. The automatically numbered field that is frequently used in access. After being imported to mssql, it is not an auto-incrementing int and needs to be set manually, change the ID of the Imported
Datediff Function
Returns the value of variant (long), indicating the number of time intervals between two specified days.
Syntax
Datediff (interval, date1, date2 [, firstdayofweek [, firstweekofyear])
The datediff function syntax contains the
SQL statement used to calculate the number of days in the month and quarter of a given date
SQL statement used to calculate the number of days in the month and quarter of a given date
SQL statement used to calculate the number of days in the
Source: bbs.erpangzi.comAuthor: My5t3ryXxasp network hard disk v3.3.2 SQL injection 0dayI will not introduce this system much. The vulnerability involves the file MyFiles. asp ShareList. asp,Using ShareList. asp as an example, the code is as follows:
Obtain the current system time using SQL.
Date part convert (varchar (10), getdate (), 120)
Yesterday select convert (varchar (10), getdate ()-1,120)
Tomorrow select convert (varchar (10), getdate () + 1,120)
Select * from TB where time
Date functionDescription: returns the current system date.Syntax: Date Dateadd FunctionDescription: return the date of the specified interval that has been added.Syntax: dateadd (interval, number, date)Interval: required. String expression,
Note: copy a table (only copy structure, source table name: a new table name: B)Select * into B from a where 1 <> 1
Description: copy a table (copy data, source table name: A target table name: B)Insert into B (a, B, c) Select D, E, F from B;
Note: copy a table (only copy structure, source table name: a new table name: B)Select * into B from a where 1 <> 1
Description: copy a table (copy data, source table name: A target table name: B)Insert into B (a, B, c) Select D, E, F from B;
To add fields automatically, rewrite them. The automatically numbered field that is frequently used in access. After being imported to MSSQL, it is not an auto-incrementing int and needs to be set manually, change the "no" of the Imported Automatic
Note: copy a table (only copy structure, source table name: a new table name: B)Select * into B from a where 1 <> 1
Description: copy a table (copy data, source table name: A target table name: B)Insert into B (a, B, c) Select D, E, F from B;
Declare @ DT datetime
Set @ dt = getdate ()
Declare @ number intSet @ number = 3
-- 1. Specify the first or last day of the year-- A. The first day of the yearSelect convert (char (5), @ DT, 120) + '1-1'
-- B. The last day of the yearSelect
1. The first day of a monthSelect dateadd (mm, datediff (mm, 0, getdate (), 0)
2. Monday of the weekSelect dateadd (wk, datediff (wk, 0, getdate (), 0)
3. The first day of the yearSelect dateadd (YY, datediff (YY, 0, getdate (), 0)
4. The first
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.