Statistics for commonly used SQLTo count commonly used SQL statements:All data for Today:SELECT *From table namewhere DateDiff (dd,datetime Type field, GETDATE ()) =0All data for yesterday:SELECT *From table namewhere DateDiff (dd,datetime Type
/*------------------------------this week----------------------------------------*/--first day of the weekSELECT DATEADD( Day,1-(DATEPART(Weekday,getdate())+@ @DATEFIRST-1)%7,getdate()) --orSelect DateAdd(WK,DateDiff(WK,0,getdate()),0) --The last
Date and time data types
Data type
Storage (bytes)
Date Range
Accuracy
Format example
Datetime
8
January 1, 1753-December 31, 9999
3 1/3 ms
YYYY-MM-DD hh:mm:ss.nnn
All data for Today: SELECT * FROM table name where DateDiff (dd,datetime Type field, GETDATE ()) =0All data yesterday: SELECT * from table name where DateDiff (dd,datetime Type field, GETDATE ()) =1All data within 7 days: SELECT * from table name
Requirements Description :In MySQL, see how many days differ between two datesOperation Process :1. Through the DateDiff function, see how many days difference between two datesMysql> Select DateDiff('2018-06-26','2018-06-25'),DateDiff('2018-06-20','
PHP format the time several days ago, several minutes ago, etc.
Class DateFormat
{
Private static $ _ DIFF_FORMAT = array (
'Day' => '% s days ago ',
'Day _ hour' => '% s DAY % s HOUR before ',
1. Column and column conversion-common
Assume that there is a student summary table (CJ) as follows:Name subject resultZhang San Chinese 80Zhang San, mathematics 90Zhang San physical 85Li Si Chinese 85Li Si mathematics 92Li Si physical 82
Want
1. Column and column conversion-common
Assume that there is a student summary table (CJ) as follows:Name subject resultZhang San Chinese 80Zhang San, mathematics 90Zhang San physical 85Li Si Chinese 85Li Si mathematics 92Li Si physical 82
Want
* Description: 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
Original address: http://blog.csdn.net/kiki113/article/details/4105929 row and column conversion and other classic SQL statements
1. -- column and column Conversion
Original table: name, subject scoreZhang San Chinese 80Zhang San, mathematics
1. Column and column Conversion
The data structure of the original table (Here It Can Be A view V_AnswerList), as shown in:
Write the stored procedure:
Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/--
A. the first day of a month
Select dateadd (mm, DATEDIFF (mm, 0, getdate (), 0)
B. Monday of the week
Select dateadd (wk, DATEDIFF (wk, 0, getdate (), 0)
C. The first day of a year
Select dateadd (yy, DATEDIFF (yy, 0, getdate (), 0)
D. The first
Advanced SQL Server database operations(1) Batch Processing(2) variables(3) Logical Control(4) Functions(5) Advanced Query
*/
(1) Batch ProcessingCompile Multiple SQL statements as a whole, generate an execution plan, and then execute!The key to
On the Internet, I often see that some people are overwhelmed by some SQL statements. Now I want to share some of my favorite SQL statements with you.
1.Conversion of rows and columns-common
Assume that there is a student summary table (CJ) as
For example, if you want to find a member registered on the website between-10-12 and-10-31, select a date and click "query, it was found that the information of the registered members was not displayed at all. The results were the same after
Javascript compares the days between two dates and the javascript days$ (Function (){Var starttime = transdate ("15:53:00 ");Var endtime = transdate ("15:53:00 ");Var now = "'" + new Date (). getTime () + "'";Var nowtime = now. substr (1, 10 );If
1. Column and column conversion-common Assume that there is a student summary table (CJ) as follows:Name subject resultZhang San Chinese 80Zhang San, mathematics 90Zhang San physical 85Li Si Chinese 85Li Si mathematics 92Li Si physical 82 Want to
1. Column and column conversion-common
Assume that there is a student summary table (CJ) as follows:Name subject resultZhang San Chinese 80Zhang San, mathematics 90Zhang San physical 85Li Si Chinese 85Li Si mathematics 92Li Si physical 82
Want to
SQL Date Time Subtraction statementThis tutorial takes advantage of the DateDiff function to subtract the date of the database tutorial Oh, the following is written n about the Mssql date subtraction method.Subtract two dates in SQL1, Days of
ASP Birthday Automatic Reminder program with ASP, debugging through, the use of convenient-asp birthday automatically remind small programs with the preparation of ASP, debug, easy to Use
method One:
Originally written on a class site for the
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.