Dates & Time
Difference |
DATEDIFF(interval,date1,date2) |
Relative +/- |
DATEADD(interval,PosOrNeg#,date) |
Date Part String |
DATENAME(interval,date) |
Date Part Integer |
DATEPART(interval,date) |
Current DT |
GETDATE( ) |
Quick Part |
YEAR(date) / MONTH(date) / DAY(date) |
Change Datatype |
CAST(date AS type) |
Change Format |
CONVERT(type,date,style) |
|
|
Interval
Year |
year, yyyy, yy |
Quarter |
quarter, qq, q |
Month |
month, mm, m |
Day of Year |
dayofyear |
Day of Month |
day, dy, y |
Week of Year |
week, ww, wk |
Day of Week |
weekday, dw, w |
Hour |
hour, hh |
Minute |
minute, mi, n |
Second |
second, ss, s |
Millisecond |
millisecond, ms |
Data Types
String Types |
CHAR(n) |
1-8000 |
|
VARCHAR(n) |
1-8000/max |
|
TEXT |
<= 2GB |
|
NCHAR(n) |
1-4000 |
|
NVARCHAR(n) |
1-4000/max |
|
NTEXT |
<= 1GB |
|
BINARY(n) |
1-8000 |
|
VARBINARY(n) |
1-8000/max |
|
IMAGE |
<= 2GB |
Numeric Types |
BIT |
(0/1/NULL) |
|
TINYINT |
0-255 |
|
SMALLINT |
-32k-32k |
|
INT |
-2B-2B |
|
BIGINT |
-19-19 #s |
|
DECIMAL(n,d) |
1-18,0-X |
|