-
1. First of all, the most commonly used is getdate, as shown in the figure below, to directly get the latest date.
2. Then there is getshortdate, as shown in the figure below, this is the following hours, minutes and seconds.
3. You may need to extract it after getting the date, so use convert, of which 23 format is more commonly used.
4. Then the format of 120 is also very commonly used, as shown in the figure below.
5. Next, there is 108 to directly obtain hours, minutes and seconds, as shown in the figure below.
6. Finally, you can also use 111 to replace the date concatenating characters with slashes, as shown in the figure below.
-
1. DateAdd() method description.
SQL Server provides the DateAdd function to obtain the date after a specified interval for a certain date.
1.Definitions and Usage.
The dateAdd() function adds or subtracts the specified time interval from the date.
2.Grammar.
dateadd(datepart,number,date)
The date parameter is a valid date expression. number is the number of intervals you wish to add; This number is positive for time in the future and negative for time in the past.
The datepart parameter can be the following values:
datepart
Abbreviated year yy, yyyy
Quarterly qq, q
Month mm, m
Mid-year day dy, y
Day dd, d
Week wk, ww
Day dw, w
Hours hh minutes mi, n
seconds ss, s
Millisecond ms subtle mcs
The nanosecond ns instance assumes that we have the following"orders"Table:
orderid
productname
orderdate
computer' 2016-12-29
Now, we want to:"orderdate"Add 2 days so you can find the payment date.
We use the following select statement:
select orderid,dateadd(day,2,orderdate) as orderpaydatefrom orders
Result: orderid
orderpaydate
2. SQL**.
print dateadd(day, -3, getdate())
3. Run the test.
05 20 2017 3:10pm
-
The function datename can be used to return hours and minutes that represent the specified time field. select datename(hour hh h, '2017-10-15 10:30:
00'- Return: 10, that is, 10 hours. select datename(minute mi n, '2017-10-15 10:
30:00'- Return: 30, that is, 30 minutes.
Extended information: 1. SQL language is the abbreviation of Structured Query Language. SQL is a database query and programming language for accessing data and querying, updating, and managing relational database systems; It is also an extension for database script files.
2. SQL language is a high-level non-procedural programming language that allows users to work on high-level data structures. It does not require the user to specify the method of data storage, nor does it require the user to understand the specific data storage method, so different database systems with completely different underlying structures can use the same structured query language as the interface for data input and management. SQL language statements can be nested, which gives him great flexibility and powerful features.
-
='Local time.
Week. 'Year.
Hours are done with this function. datetime
-
datename
Returns hours and minutes that represent the specified time field
select
datename(hour
hhh,2004-10-15
Return: 10select
datename(minute
min,2004-10-15
Return: 30 function parameters function.
getdate(
- Returns the current date and time of the system.
datediff
interval, date1, date2) -- take interval
The specified method returns date2
The difference between two dates and date1.
date2-date1
dateadd
interval,number,date) -- add the date after number in the way specified by intervalDATEPART
interval,date)
- In the Returned DateDate field, the integer value corresponding to the specified part of the interval datename is returned
interval,date)
In the Date and Interval parameters, the value of the interval parameter corresponding to the specified part of the interval parameter is as follows: value reduction.
Write (sqlserver).
access
and asp to state the year
yyyyyyy year 1753
quarterqqq
Season 1 4monthmmm
January 1 12day
ofyeardyy
The number of days in a year, the day of the year.
Daydd days, 1-31
weekdaydww
The number of days in a week, the day of the week.
1-7week
wkww week, week of the year 0
51hourhhh
0 23 minutemin
Minute 0 59secondsss
seconds 0 59millisecondms-
Milliseconds 0 999
-
It's more complete here, take a look.
--Supplemental --- value reduction.
Write a note yearyy.
quarterqq.
1~4month
mm 1 12 on month
Daydd, 1-31
weekday
dwThe number of days of the week, the day of the week.
1-7week
wk week, week of the year 0
51hour
0 23 at hh
minute
mi minute 0 59
secondss.
0~59millisecond
ms milliseconds 0
999hour
0 23 at hh
minute
mi minute 0 59
secondss.
Aren't 0 59 just hours, minutes, and seconds?
Brother, your situation is the same as mine, I'm also reinstalled n times, it's not bad, it's not my computer problem. Graphics card or something, mine is awesome. I've had this problem since it came out.。。 >>>More
It's okay, it's not fast, but the 2000-meter breaststroke is really not good to swim, and it's not good to swim... I'm a few 800s at most to keep fit! Then 15 100 keep the speed! >>>More
There is no exact conclusion on this.,Because mending the knife depends on the lane hero and whether there is a hero who protects you, and the ability to protect your hero is also very important.。。。 There is no way to explain this, and it is recommended that the landlord call more passers-by and slowly understand. If you want a data test, there are also under the test.,I've tried.,It's a stand-alone mending.,Make up for 10 minutes.,Positive and negative supplements add up to 80 (can't bring any equipment) and then heroes.。 >>>More
Your situation is typical for booting up and needs to be warmed up. Under normal circumstances, the computer does not need to be warmed up, it is required"Preheat"If it takes a while to boot up normally, you can check whether the capacitors on the motherboard are normal, especially some of the capacitors around the processor. If capacitance is found. >>>More
1, sin508=sin(508-360)=sin148 sine is a subtraction function in the second quadrant, so sin144 is larger. >>>More