Sql server® 2012 t-sql fundamentals



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

partdt_val1dt_val2)

For example, the following code returns the difference in terms of days between two values.

SELECT DATEDIFF(day, '20080212', '20090212');

This code returns the output 366.

Ready for a bit more sophisticated use of the DATEADD and DATEDIFF functions? You can use the 

following code in versions prior to SQL Server 2008 to set the time component of the current system 

date and time value to midnight.

SELECT 

  DATEADD( 

    day,  

    DATEDIFF(day, '20010101', CURRENT_TIMESTAMP), '20010101');

This is achieved by first using the DATEDIFF function to calculate the difference in terms of whole 

days between an anchor date at midnight (‘20010101’ in this case) and the current date and time (call 

that difference diff). Then, the DATEADD function is used to add diff days to the anchor. You get the 

current system date at midnight.

Interestingly, if you use this expression with a month part instead of a day, and make sure to use an 

anchor that is the first day of a month (as in this example), you get the first day of the current month.

www.it-ebooks.info




Download 10,93 Mb.

Do'stlaringiz bilan baham:
1   ...   128   129   130   131   132   133   134   135   ...   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