Добавил:
Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
Build Your Own ASP.NET 2.0 Web Site Using CSharp And VB (2006) [eng].pdf
Скачиваний:
77
Добавлен:
16.08.2013
Размер:
15.69 Mб
Скачать

Date and Time Functions

Figure 8.9. Employees’ first names

FirstName

------------------------------------------------------------------

Zak Jessica Ted Shane David Geoff

(6 row(s) affected)

Note that the query isn’t bulletproof—it’s only suitable for western-style names. If an employee had no spaces in his or her name (imagine, for instance, that we hired Cher to work as an Engineer), then the CHARINDEX function would return -1, indicating that there was no space character in the name. The SUBSTRING function would then return NULL, so the list of results would be flawed.

Date and Time Functions

Date and time functions facilitate the manipulation of dates and times that are stored within your database. These functions work with arguments of the datetime type. Here are some of the most useful ones:

GETDATE

returns the current date and time

317