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

bin2hex - Converting Binary Strings into Hexadecimal Character Strings in SQL Server
How To Convert Binary Strings into Hexadecimal Character Strings in SQL Server? When a query returns a binary string value to the client tool, it will be displayed by the client tool as hexadecimal digits in a character string format. But they are hexadecimal digits on the display window, not in the...
2017-02-25, 266👍, 0💬

Date/Time Data Type Comparison in SQL Server Transact-SQL
What are differences between date and time data types in SQL Server Transact-SQL? I want to compare of date and time data types? Here is a comparison table of all date and time data types supported in SQL Server Transact-SQL: Data type Storage size Precision Default Format / (bytes) Value range ----...
2017-02-25, 264👍, 0💬

Date/Time Operations and Functions in SQL Server Transact-SQL
Where to find answers to frequently asked questions on Date/Time Operations and Functions in SQL Server Transact-SQL? Here is a list of frequently asked questions and their answers compiled by FYIcenter.com DBA team on Date/Time Operations and Functions in SQL Server Transact-SQL. Clear answers are ...
2017-02-25, 248👍, 0💬

Verify Time Precision in SQL Server Transact-SQL
How to verify the precession of the server system time in SQL Server Transact-SQL? You can run a WHILE loop to check the precision of server system time in Transact-SQL as shown below: DECLARE @var DATETIME2(7); DECLARE @count INT = 0; WHILE @count<100 BEGIN SET @count = @count + 1; SET @var = SY...
2017-02-22, 274👍, 0💬

Adding and Removing Days on Date and Time Values in SQL Server
How To Add or Remove Days on Date and Time Values in SQL Server Transact-SQL? SQL Server 2005 only support two operators on data and time values: + (Add): Adding days to a date and time value. - (Subtract): Removing days from a date and time value. Note that to add or subtract days on a date and tim...
2017-02-22, 272👍, 0💬

Converting DATETIME and NUMERIC Values in SQL Server
Are DATETIME and NUMERIC Values Convertible in SQL Server Transact-SQL? Are datetime and numeric value convertible? The answer is yes. Here are the main rules on DATATIME and NUMERIC value conversions: During the conversion a DATETIME value will be treated as a NUMERIC value with the number of days ...
2017-02-22, 270👍, 0💬

Converting Date and Time Values into Integers in SQL Server
Can Date and Time Values Be Converted into Integers in SQL Server Transact-SQL? Can date and time values be converted into integers? The answer is yes. The resulting integer will be the number days relative the base date: Jan 1, 1900. The time of the day will be rounded to days. But there several ru...
2017-02-22, 259👍, 0💬

Converting Integers into Date and Time Values in SQL Server
Can Integers Be Converted into Date and Time Values in SQL Server Transact-SQL? Can integers be converted into date and time values? The answer is yes. The input integer will be used as the number of days relative to the base date: Jan 1, 1900. The time of the day will be set to 0, midnight of the d...
2017-02-22, 207👍, 0💬

DATEADD() Function Usage Examples in SQL Server
How To Use DATEADD() Function in SQL Server Transact-SQL? DATEADD() is a very useful function for manipulating date and time values. The following tutorial exercise shows you some good DATEADD() usage examples: -- Incrementing 1 year on a leap date DECLARE @birth_date DATETIME; SET @birth_date = '20...
2017-02-20, 304👍, 0💬

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, 251👍, 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, 245👍, 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, 210👍, 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, 194👍, 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, 260👍, 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, 249👍, 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, 244👍, 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, 212👍, 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, 184👍, 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, 276👍, 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, 264👍, 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, 246👍, 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, 231👍, 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, 230👍, 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, 236👍, 0💬

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