Tham khảo tài liệu 'mastering sql server 2000- p5', công nghệ thông tin, cơ sở dữ liệu phục vụ nhu cầu học tập, nghiên cứu và làm việc hiệu quả | 170 CHAPTER 5 TRANSACT-SQL OVERVIEW AND BASICS TABLE SQL SERVER DATEPART CONSTANTS Constant Meaning yy or yyyy Year qq or q Quarter mm or m Month wk or ww Week dy or y dd or d Day of year 1 to 366 Day hh Hour mi or n Minute ss or s Second ms Millisecond For example the DATEADD function takes as arguments a datepart a quantity and a date. It returns the result of adding the given quantity of the given datepart to the given date. Thus to add three days to the current date you could use the following expression PRINT DATEADD d 3 GETDATE WARNING The datepart constants are not strings and thus should not be enclosed in single quotes. Here s the full list of available date and time functions DATEADD adds time to a date. DATEDIFF reports the number of dateparts between two dates. DATENAME extracts textual names for example February or Tuesday from a date. DATEPART returns the specified datepart from a specified date. DAY returns the day from a date. GETDATE returns the current date and time. MONTH returns the month from a date. YEAR returns the year from a date. FUNCTIONS 171 Mathematical Functions SQL Server supplies almost two dozen mathematical functions for manipulating integer and floating-point values. These functions include all the common functions that you d naturally expect to find in any programming language. Table lists the available mathematical functions. TABLE MATHEMATICAL FUNCTIONS IN T-SQL Function Meaning ABS Absolute value ACOS Arccosine ASIN Arcsine ATAN Arctangent ATN2 Arctangent of the angle defined by two angles CEILING Smallest integer greater than the expression COS Cosine COT Cotangent DEGREES Converts radians to degrees EXP Exponential FLOOR Largest integer smaller than the expression LOG Base 2 logarithm LOG10 Base 10 logarithm PI The constant pi POWER Exponentiation operator RADIANS Converts degrees to radians RAND Random number generator ROUND Rounds floating-point numbers by precision SIGN Sign of the expression SIN Sine SQRT .