Sql server® 2012 t-sql fundamentals



Download 10,93 Mb.
Pdf ko'rish
bet134/443
Sana26.01.2022
Hajmi10,93 Mb.
#411755
1   ...   130   131   132   133   134   135   136   137   ...   443
Bog'liq
BookSQL

partdt_val)

Valid values for the part argument include yearquartermonthdayofyeardayweekweekday

hourminutesecondmillisecondmicrosecondnanosecondTZoffset, and ISO_WEEK. The last four 

parts are available in SQL Server 2008 and SQL Server 2012. As I mentioned earlier, you can use ab-

breviations for the date and time parts, such as yy instead of yearmm instead of monthdd instead 

of day, and so on.

For example, the following code returns the month part of the input value.

SELECT DATEPART(month, '20090212');

This code returns the integer 2.

The 

YEAR



MONTH

, and 

DAY

 Functions

The YEARMONTH, and DAY functions are abbreviations for the DATEPART function returning the 

integer representation of the year, month, and day parts of an input date and time value.

Syntax

YEAR(dt_val)

MONTH(dt_val)

DAY(dt_val)

www.it-ebooks.info



86  

Microsoft SQL Server 2012 T-SQL Fundamentals

For example, the following code extracts the day, month, and year parts of an input value.

SELECT 


  DAY('20090212') AS theday, 

  MONTH('20090212') AS themonth, 

  YEAR('20090212') AS theyear;

This code returns the following output.

theday      themonth    theyear 

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

12          2           2009

The 

DATENAME

 Function

The DATENAME function returns a character string representing a part of a date and time value.



Syntax

DATENAME(dt_val


Download 10,93 Mb.

Do'stlaringiz bilan baham:
1   ...   130   131   132   133   134   135   136   137   ...   443




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©hozir.org 2024
ma'muriyatiga murojaat qiling

kiriting | ro'yxatdan o'tish
    Bosh sahifa
юртда тантана
Боғда битган
Бугун юртда
Эшитганлар жилманглар
Эшитмадим деманглар
битган бодомлар
Yangiariq tumani
qitish marakazi
Raqamli texnologiyalar
ilishida muhokamadan
tasdiqqa tavsiya
tavsiya etilgan
iqtisodiyot kafedrasi
steiermarkischen landesregierung
asarlaringizni yuboring
o'zingizning asarlaringizni
Iltimos faqat
faqat o'zingizning
steierm rkischen
landesregierung fachabteilung
rkischen landesregierung
hamshira loyihasi
loyihasi mavsum
faolyatining oqibatlari
asosiy adabiyotlar
fakulteti ahborot
ahborot havfsizligi
havfsizligi kafedrasi
fanidan bo’yicha
fakulteti iqtisodiyot
boshqaruv fakulteti
chiqarishda boshqaruv
ishlab chiqarishda
iqtisodiyot fakultet
multiservis tarmoqlari
fanidan asosiy
Uzbek fanidan
mavzulari potok
asosidagi multiservis
'aliyyil a'ziym
billahil 'aliyyil
illaa billahil
quvvata illaa
falah' deganida
Kompyuter savodxonligi
bo’yicha mustaqil
'alal falah'
Hayya 'alal
'alas soloh
Hayya 'alas
mavsum boyicha


yuklab olish