A function that calculates a two time lag
'******************************
'|| Function Timediff (Sbegin, SEnd)
'|| This function calculates the difference of two times and can be used without changing the
'|| Author: Machinecat 2001/10/26
'*********
One-time modification of the closed source Entity Provider assembly to be compatible with the new EntityFramework process, assembly
After reading this article, you will know how to directly modify a DLL without the source code to remove the strong naming restrictions on the DLL, add your "friend assembly" directly on the Assembly (a special Attribute that is applied to the Assembly so that the internal type in the Assembly can be directly called by other assembly) ". Similarly, you can use this
date to "", and then add it to "" to obtain a special date, this technique can be used to calculate many different dates.
DECLARE @ Date DATETIME
SET @ Date = GETDATE ()
Select dateadd (MONTH, DATEDIFF (MONTH, '2017-01-01 ', @ Date), '2017-01-01') AS 'Day of the MONTH'
-- Simplified algorithm. According to the Time Representation of SQL Server, '2017-01-01 'can be replaced by 0.
Select dateadd (MONTH, DATEDIFF
-- Added the weekly times of the month and year of the date!-- Sunday is counted as "last week "! (Note the differences between weekofyear, weekofmonth, myweekofyear, and myweekofmonth)-- Note that the datename value varies depending on the SQL Server language version or date format!-- The test environment is: SQL Server 2000 Simplified Chinese version + windows Simplified Chinese version
Declare @ datetimeSet @ = '2017-02-25 11:00:50 '-- 1995 is a Sunday.
Select @ as date, Dateadd (year,
/*************************************** **************************************** ******************************/-- Calculate the overtime hours for non-fixed employees/*************************************** **************************************** ******************************/Create proc recountworkhourfordf@ Begindate varchar (10 ),@ Enddate varchar (10)As------------- Delete the overtime record on the Operation Date ------------------------------------------------Delete from workhourdetail
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, the day after the given dateSelect dateadd (day, 1, @ date) as 'Next Day'Go
-Calculate the first day of the month of the given date at the beginning of the month.-This calculation technique is to calculate the number of time intervals from the curr
/*--quarterofhalfyearUpdate Bas_datetimeSet quarterofhalfyear = case when (month (RQ) between 1 and 3) or (for month (RQ) between 7 and 9) then 1 else 2 endGo*/--quarterofyearUpdate Bas_datetimeSet quarterofyear = caseWhen (Rq) between 1 and 3) Then ' first quarter 'When (RQ) between 4 and 6) Then ' second quarter 'When (RQ) between 7 and 9) Then ' third quarter 'Else ' Quarter ' endGo--weekdayUpdate Bas_datetimeSet [weekday]= datename (WEEKDAY,RQ)Go --monthofhalfyear/*Update Bas_datetimeSet mon
given date, Num is positive, plus, minusSelect ' 19901221 ' as ' given date ', dateadd (year,2, ' 19901221 ') as ' plus 2 years ', dateadd (year,-2, ' 19901221 ') As ' minus 2 years ', dateadd (month,12, ' 19901221 ') as ' plus 12 months ', dateadd (month,-12, ' 19901221 ') as ' minus 12 months ', DateAdd (day,31, ' 19901221 ') as ' plus 31 days ', DateDiff (part,dtvalue1.dtvalue2) calculates the interv
This article consists of three parts, collecting several methods for processing MSSQL datetime on the Internet. Here, we will sort the data according to my collection order.
Part 1: SQL statistics for this month and this weekStatistics for this month (MySQL)Select * from booking where month (booking_time) = month (curdate () and year (booking_time) = year (curdate ())
Weekly Statistics (MySQL)Select * From spf_booking where month (booking_time) = month (curdate () and week (booking_time) = Week
This is the SQL script that calculates the first day of the one month:SELECT DATEADD (mm, DATEDIFF (Mm,0,getdate ()), 0)--the first day of the monthSELECT DATEADD (mm, DATEDIFF (Mm,0,getdate ())-1, 0)-the first day of the monthSELECT DATEADD (Ms,-3,dateadd (mm, DATEDIFF (M,0,getdate ()) +1, 0))--the last day of the monthSELECT DATEADD (Ms,-3,dateadd (mm,
Tags: blog http ar using SP strong on Art logFind an article on the internet, pretty good Oh O (∩_∩) o~This is the SQL script that calculates the first day of the one month:SELECT DATEADD (mm, DATEDIFF (Mm,0,getdate ()), 0)--the first day of the monthSELECT DATEADD (mm, DATEDIFF (Mm,0,getdate ())-1, 0)-the first day of the monthSELECT DATEADD (Ms,-3,dateadd (mm, DATEDIF
This is the SQL script that calculates the first day of the one month:SELECT DATEADD (mm, DATEDIFF (Mm,0,getdate ()), 0)--the first day of the monthSELECT DATEADD (mm, DATEDIFF (Mm,0,getdate ())-1, 0)-the first day of the monthSELECT DATEADD (Ms,-3,dateadd (mm, DATEDIFF (M,0,getdate ()) +1, 0))--the last day of the monthSELECT DATEADD (Ms,-3,dateadd (mm,
Categories: Database Problems
Keywords: Date
Correlation: Author: Unknown Source: xpilot's blog
Reference: [0]
Http://goaler.xicp.net/TrackBack.asp? Logid = 508
Text: [Large, medium, and small] [recommend this log to a Friend] Generally, you need to get the current date and calculate some other dates, for example, your
Program You may need to determine the first or last day of a month. Most of you probably know how to divide a date (year, month, day, and so on ), then, just use th
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 a date (year, month, day, and so on ), then, just use the split year, month, and day to calculate the date you need in several functions! In this article, I will show you how to use the dateadd and datediff functions to calculate different dates that may
Usually, you need to get the current date and calculate some other date, for example, your program may need to judge 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 to calculate the date you need! In this article, I'll show you how to use the DateAdd and DATEDIFF functions to calculate some of the different dates you might
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 a date (year, month, day, and so on ), then, just use the split year, month, and day to calculate the date you need in several functions! In this article, I will show you how to use the dateadd and datediff functions to calculate different dates that may
Usually, you need to get the current date and calculate some other date, for example, your program may need to judge 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 to calculate the date you need! In this article, I'll show you how to use the DateAdd and DATEDIFF functions to calculate some of the different dates you might
Parallel Database for OLTP and OLAPJust ASurvey article on materials in parallel database products andTechnologies for OLTP/OLAP applications. It mainly covers majorCommercial/academic efforts on developing parallel DBMS to solve theEver growing large amount of relational data processing problem.Part I–parallel DBMSs1.1 Parallel Database for OLAP (SHARED-NOTHING/MPP)TeraData–teradata Home–
Network collection
Generally, you need to obtain the current date and calculate some other dates, such as your Program You may need to determine the first or last day of a month. Most of you probably know how to divide a date (year, month, day, and so on ), then, just use the split year, month, and day to calculate the date you need in several functions! In this article Article I will show you how to use the dateadd and datediff functions to calculat
Tags: des style blog http color using OS strongSELECT * FROM table WHERE convert (Nvarchar, DateAndTime, 111) = CONVERT (Nvarchar, GETDATE (), 111) ORDER by DateAndTime DESCRecord of the Month
SELECT * FROM table WHERE DateDiff (Month,[dateadd],getdate ()) =0
Week record
SELECT * FROM table WHERE DateDiff (Week,[dateadd],getdate ()) =0
Day recordSELECT *
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.