<< < 1 2 3 4 5 6 7 8 9 10 > >>   Sort: Rank

DATEDIFF() - Calculating DATETIME Value Differences in SQL Server
How To Calculate DATETIME Value Differences Using the DATEDIFF() Function in SQL Server Transact-SQL? If you want to calculate the difference between two date and time values, you can use the DATEDIFF() function in the following format: DATEDIFF(datepart, startdate, enddate) returns INT: "startdate"...
2017-02-20, 356👍, 0💬

Incrementing or Decrementing Parts of DATETIME Values in SQL Server
How To Increment or Decrement Parts of DATETIME Values in SQL Server Transact-SQL? If you want to increment or decrement one part of a date and time value, you can use the DATEADD() function in the following format: DATEADD(datepart, number, date) returns DATETIME: "date" - the input date "number" -...
2017-02-20, 311👍, 0💬

Date and Time Functions Supported by SQL Server 2005 in SQL Server
What Are the Date and Time Functions Supported by SQL Server 2005 in SQL Server Transact-SQL? SQL Server 2005 supports n character string functions: DATEADD(datepart, number, date) - Returning the same date and time value with one part added with the "number". DATEDIFF(datepart, startdate, enddate) ...
2017-02-20, 258👍, 0💬

Subtracting a DATETIME Value from Another DATETIME Value in SQL Server
Can a DATETIME Value Be Subtracted from Another DATETIME Value in SQL Server Transact-SQL? Can a datetime value be subtracted from another datetime value? The answer is yes. The subtract operation can be performed by the subtract operator (-) as: datetime1 - datetime2: Returning a DATETIME value cal...
2017-02-20, 240👍, 0💬

Calculating Age in Days, Hours and Minutes in SQL Server
How To Calculate Age in Days, Hours and Minutes in SQL Server Transact-SQL? On many Web sites, news items or blog articles are displayed with a publishing data and time represented in days, hours and minutes. To do this you can use the DATEDIFF() function with a simple algorithm as shown in the tuto...
2017-02-14, 357👍, 0💬

Getting Year, Month and Day Out of DATETIME Values in SQL Server
How To Get Year, Month and Day Out of DATETIME Values in SQL Server Transact-SQL? You can use DATEPART() to get any part of the DATETIME value. But to get year, month and day, you can use 3 specific functions: YEAR(), MONTH() and DAY(). These functions are equivalent to DATEPART() as: YEAR(date) = D...
2017-02-14, 354👍, 0💬

Difference Between GETDATE() and GETUTCDATE() in SQL Server
What Is the Difference Between GETDATE() and GETUTCDATE() in SQL Server Transact-SQL? The difference between GETDATE() and GETUTCDATE() is time zone number of the SQL Server machine. The tutorial exercise below gives you a good example: DECLARE @local_time DATETIME; DECLARE @gmt_time DATETIME; SET @...
2017-02-14, 328👍, 0💬

Getting Parts of DATETIME Values as Integers in SQL Server
How To Get Parts of DATETIME Values as Integers in SQL Server Transact-SQL? Sometimes, you want to one specific part of a DATETIME value as an integer to be used in your own date and time calculations. This can be done by using the DATEPART() function in the following format: DATENAME(datepart, date...
2017-02-14, 256👍, 0💬

Getting Month and Weekday Names from DATATIME Values in SQL Server
How To Get Month and Weekday Names from DATETIME Values in SQL Server Transact-SQL? In DATETIME values, the month part and weekday part have names. You can use the DATENAME() function to get the month name and weekday name from a DATETIME value in the following format: DATENAME(datepart, date) retur...
2017-02-14, 231👍, 0💬

Formatting Time Zone in +/-hh:mm Format in SQL Server
How To Format Time Zone in +/-hh:mm Format in SQL Server Transact-SQL? From the previous tutorial, you know how to calculate the time zone value by using GETDATE() and GETUTCDATE() functions. But how can you format that time zone value in a nice looking format like +05:45 or -04:00? Unfortunately, S...
2017-02-08, 365👍, 0💬

CONVERT() - Formatting DATETIME Values to Strings in SQL Server
How To Format DATETIME Values to Strings with the CONVERT() Function in SQL Server Transact-SQL? SQL Server 2005 offers no functions to format DATETIME values in your own format patterns. But it does provide you a number of pre-defined format patterns that you can use with the CONVERT(char_type, dat...
2017-02-08, 358👍, 0💬

Truncating DATETIME Values to Dates without Time in SQL Server
How To Truncate DATETIME Values to Dates without Time in SQL Server Transact-SQL? Assuming that you have some date and time, DATETIME, values, and you want to work with dates only. You want to truncate them to dates without time, or with time of 00:00:00.000. Again, SQL Server offers no simple solut...
2017-02-08, 300👍, 0💬

Working with NULL Values in SQL Server Transact-SQL
Where to find answers to frequently asked questions on Working with NULL Values in SQL Server Transact-SQL? Here is a list of frequently asked questions and their answers compiled by FYIcenter.com DBA team on Working with NULL Values in SQL Server Transact-SQL. Clear explanations and tutorial exerci...
2017-02-08, 283👍, 0💬

Setting New Values to Parts of a DATETIME Value in SQL Server
How To Set Different Parts of a DATETIME Value in SQL Server Transact-SQL? In SQL Server, you can get different parts of a DATETIME value with the DATEPART() functions. But there is no function that allows you to set different parts to a DATETIME value. For example, you a date_of_birth column as DAT...
2017-02-08, 280👍, 0💬

Assigning NULL Values to Variables or Columns in SQL Server
How To Assign NULL Values to Variables or Columns in SQL Server Transact-SQL? The rule for assigning NULL values to variables or table columns is simple: Use keyword "NULL" directly as normal values. "NULL" can be used in SET statements to assign NULL values to variables. "NULL" can be used in SET c...
2017-02-05, 291👍, 0💬

NULL Values Involved in Arithmetic Operations in SQL Server
What Happens If NULL Values Are Involved in Arithmetic Operations in SQL Server Transact-SQL? If NULL values are involved in arithmetic operations, the result will be numeric NULL values. The following tutorial script shows you some good examples: SELECT 7+NULL; GO ----------- NULL SELECT 10.02*NULL...
2017-02-05, 287👍, 0💬

What Are NULL Values in SQL Server
What Are NULL Values in SQL Server Transact-SQL? A NULL value is a special value that represents an unknown value. SQL Server supports NULL values with the following features: All data types used for table columns support NULL values. In another word, NULL values can be stored in database tables. In...
2017-02-05, 278👍, 0💬

NULL Values Involved in Datetime Operations in SQL Server
What Happens If NULL Values Are Involved in Datetime Operations in SQL Server Transact-SQL? If NULL values are involved in datetime operations, the result will be datetime NULL values. The following tutorial script shows you some good examples: USE FyiCenterData; GO SELECT GETDATE()+NULL; GO -------...
2017-02-05, 269👍, 0💬

NULL Values Involved in String Operations in SQL Server
What Happens If NULL Values Are Involved in String Operations in SQL Server Transact-SQL? If NULL values are involved in string operations, the result will be string NULL values. The following tutorial script shows you some good examples: SELECT 'FyiCenter'+NULL; GO ---------- NULL SELECT LEN(NULL);...
2017-02-05, 263👍, 0💬

ISNULL() - Replacing NULL Values in Expressions in SQL Server
How To Replace NULL Values in Expressions using ISNULL() in SQL Server Transact-SQL? As you learned from previous tutorials, NULL values presented in expressions will cause the final results to be NULL. Sometimes, you want NULL values to be replaced with some default values, like 0, '', or 'NULL', s...
2017-02-03, 361👍, 0💬

"IS NULL" - Testing NULL Values in SQL Server
How To Test NULL Values Properly in SQL Server Transact-SQL? From previous tutorials, you learned that comparing expressions with NULL will always result NULL. So you can not use comparison operators to test if an expression represents a NULL value or not. To test expressions for NULL values, you sh...
2017-02-03, 306👍, 0💬

NULL Values Involved in Boolean Operations in SQL Server
What Happens If NULL Values Are Involved in Boolean Operations in SQL Server Transact-SQL? If NULL values are involved in Boolean operations, the result will vary depending on the operator type. For AND operator, FALSE takes precedence over NULL. The result can be summarized in a table below: AND TR...
2017-02-03, 305👍, 0💬

NULL Values Involved in Bitwise Operations in SQL Server
What Happens If NULL Values Are Involved in Bitwise Operations in SQL Server Transact-SQL? If NULL values are involved in bitwise operations, the result will be binary NULL values. The following tutorial script shows you some good examples: SELECT 1 | NULL; GO ----------- NULL SELECT 707 &amp; N...
2017-02-03, 296👍, 0💬

NULL Values Involved in Comparison Operations in SQL Server
What Happens If NULL Values Are Involved in Comparison Operations in SQL Server Transact-SQL? If NULL values are involved in comparison operations, the result will be Boolean NULL values. This behavior is very interesting because you would expect a comparison operation returns only one of the two va...
2017-02-03, 296👍, 0💬

<< < 1 2 3 4 5 6 7 8 9 10 > >>   Sort: Rank