-Поиск по дневнику

Поиск сообщений в rss_peterlsql

 -Подписка по e-mail

 

 -Постоянные читатели

 -Статистика

Статистика LiveInternet.ru: показано количество хитов и посетителей
Создан: 08.06.2009
Записей:
Комментариев:
Написано: 0


A glance at SQL Server Denali CTP3 - DATEFROMPARTS

Среда, 13 Июля 2011 г. 11:18 + в цитатник

There is a new function in SQL Server Denali named DATEFROMPART. What is does, is to calculate a date from a number of user supplied parameters such as Year, Month and Date.

Previously you had to use a formula like this

DATEADD(MONTH, 12 * @Year + @Month - 22801, @Day)

to calculate the correct datevalue from the parameters. With the new DATEFROMPARTS, you simple write

DATEFROMPARTS(@Year, @Month, @Day)

and you get the same result, only slower by 22 percent. So why should you use the new function, if it's slower?
There are two good arguments for this

1) It is easier to remember
2) It has a built-in validator so that you cannot "spill" over the current month.

For the old way of doing this, using @Year = 2009, @Month = 2 and @Day = 29 you would end up with a date of 2009-02-28 and the DATEFROMPARTS will give you an error message.

http://weblogs.sqlteam.com:8081/peterl/archive/2011/07/13/a-glance-at-sql-server-denali-ctp3-datefromparts.aspx

Метки:  

 

Добавить комментарий:
Текст комментария: смайлики

Проверка орфографии: (найти ошибки)

Прикрепить картинку:

 Переводить URL в ссылку
 Подписаться на комментарии
 Подписать картинку