Vinhtrinh - Tin Tức Hay, Siêu Hot Cập Nhật Hàng Ngày
  • Home
  • Bất Động Sản
  • Công Nghệ
  • Luật
  • Tài Chính
No Result
View All Result
  • Home
  • Bất Động Sản
  • Công Nghệ
  • Luật
  • Tài Chính
No Result
View All Result
Vinhtrinh - Tin Tức Hay, Siêu Hot Cập Nhật Hàng Ngày
No Result
View All Result

DatePart, DateAdd and DateDiff functions in SQL Server Part 27

admin by admin
June 5, 2020
in Tổng Hợp
38
DatePart, DateAdd and DateDiff functions in SQL Server   Part 27



In this video we will learn about builtin date time system functions in sql server. DatePart, DateAdd and DateDiff functions in SQL Server will be discussed along with a real time example of using these functions.

Text version of the video

Slides

All SQL Server Text Articles

All SQL Server Slides

All Dot Net and SQL Server Tutorials in English

All Dot Net and SQL Server Tutorials in Arabic

Nguồn: https://vinhtrinh.com.vn

Xem thêm bài viết khác: https://vinhtrinh.com.vn/tong-hop/

Xem thêm Bài Viết:

  • Cách làm 4 món thịt ngâm mắm tỏi chua ngọt thơm ngon ngày Tết
  • Sinh năm 1998 mệnh gì, tuổi con gì, hợp tuổi nào?
  • TUỔI TÂN HỢI SINH NĂM 1971 MỆNH GÌ, HỢP MÀU GÌ, HƯỚNG NÀO TỐT
  • Mách bạn cách làm hoa ly thủ công bằng giấy xinh xắn siêu đơn giản
  • Hướng dẫn trẻ mầm non cách vẽ xe đạp đơn giản nhất
Previous Post

Biểu diễn fashion áo dài - Festival biển BR VT 2018

Next Post

MÌ CĂN XÀO SẢ ỚT món ăn chay thanh đạm làm đơn giản by Hồng Thanh Food

Next Post
MÌ CĂN XÀO SẢ ỚT món ăn chay thanh đạm làm đơn giản by Hồng Thanh Food

MÌ CĂN XÀO SẢ ỚT món ăn chay thanh đạm làm đơn giản by Hồng Thanh Food

Comments 38

  1. rajat shrivastava says:
    3 years ago

    You are a gem. Explains Tricky concepts with such ease. Thanks for this complete video tutorial series.

    Reply
  2. Panagiotis Goulas says:
    3 years ago

    Yep that was hardest video up to now. Took me long to understand literally

    Reply
  3. Maria Magurean says:
    3 years ago

    I felt the need to comment because you really helped me with your tutorials!
    Thank you, Venkat, for all the effort you make to present programming in such an easy way, no matter how noob somebody may be.
    You are the best teacher I could find on youtube. Keep up the good work! Hope it pays back…

    Reply
  4. KedWebDev2011 says:
    3 years ago

    Bravo!! Well Done!

    Reply
  5. AM Bhat says:
    3 years ago

    @Venkat : Wonder if your birthday is 10-08-1982

    Reply
  6. Rama Rocky Krishna says:
    3 years ago

    In the last 10 mins is boring and confusing it seems un necessary topic in last 10 minutes.

    Reply
  7. Alish Safarli says:
    3 years ago

    select DATEADD(year, @years, @tempdate)

    how do we find month with this code? it gives a year-adding

    Reply
  8. Stanley Sosa says:
    3 years ago

    Hi, do you have any idea or video where you can show us how to use a function "same period last year"if that exist in SQL, in order to get a a value and compare to the last year. thanks and regards.

    Reply
  9. Gowtham S.V says:
    3 years ago

    I have a doubt why are we subtracting one in case statement. For year month and days i am not able to grasp it can someone reply me .

    Reply
  10. Madhu Garg says:
    3 years ago

    please do a python video

    Reply
  11. Madhu Garg says:
    3 years ago

    Simply superb tutorial

    Reply
  12. Rakshanda Meshram says:
    3 years ago

    What is the datatype of column DateOfBirth in that table.tblEmployees, is it date time?

    Reply
  13. Trung Nguyen says:
    3 years ago

    I really like this channel. BTW The example in this video is quite complicate, can anyone explain me that in the real world application, should we move this complicate process from SQL to C#?

    Reply
  14. sunil kumar Reddy says:
    3 years ago

    select dateadd(yyyy,2010-1900,0) means why we use 1900 for what purpose
    pls give answer about that

    Reply
  15. Subhash Adhikari says:
    3 years ago

    videos with every small explanation, but i am getting python udemy ads, model looks like crow

    Reply
  16. Ompathi Madana says:
    3 years ago

    How about this query?

    declare @d1 date = '2010-12-31', @d2 date = '2011-01-01';
    declare @ds int = datediff(day, @d1, @d2);
    select @ds/365 as years, (@ds%365)/12 as months, @ds%12 days;

    Reply
  17. Sudeep Janawade says:
    3 years ago

    When do you use SET and SELECT statements?

    Reply
  18. MD ARIF says:
    3 years ago

    logic is quite complicated 😀

    Reply
  19. Bigyan Chapagain says:
    3 years ago

    Venkat is phenomenal. I wish I could meet you.

    Reply
  20. IT ICCL says:
    3 years ago

    Hi.. can you help me to find out continuously absent check in sql query in two or more table using date & time. my mail add is itkaushik@outlook.com

    Reply
  21. Trzbne says:
    3 years ago

    Thank you very much, it was an excellent tutorial! Even the more difficult part was digested 🙂 I do not believe in copy-paste learning, I do not believe, that you can learn well, if you just copy the part that is too complicated for you. If you write it by yourself, you learn more.

    Reply
  22. vadali prasad says:
    3 years ago

    Outstanding !!! Your tutorial is really easy to understand, digest and develop a carrer.. Thank you

    Reply
  23. Kenneth Hutson says:
    3 years ago

    Why does not DATENAME(YEAR, '2018/01/01') RETURN 2018? It should return 'Two-Thousand Eighteen'

    Reply
  24. Nawaf Na says:
    3 years ago

    CREATE FUNCTION FN_CountAge(@DOB DATETIME)
    RETURNS NVARCHAR(50)
    AS
    BEGIN
    DECLARE @TEMPDATE DATETIME , @YEAR INT , @MONTH INT , @DAY INT

    SELECT @TEMPDATE = @DOB

    SELECT @YEAR = DATEDIFF(YEAR,@TEMPDATE,GETDATE()) –
    CASE WHEN DATEPART(MONTH,@DOB) > DATEPART (MONTH,GETDATE())
    OR DATEPART(MONTH,@DOB) = DATEPART(MONTH,GETDATE())
    AND DATEPART(DAY,@DOB) = DATEPART(DAY,GETDATE()) THEN 1 ELSE 0 END
    SELECT @TEMPDATE = DATEADD(YEAR,@YEAR,@TEMPDATE)
    SELECT @MONTH = DATEDIFF(MONTH,@TEMPDATE,GETDATE()) –
    CASE
    WHEN DATEPART(DAY,@DOB) > DATEPART(DAY,GETDATE())
    THEN 1 ELSE 0 END
    SELECT @TEMPDATE = DATEADD(MONTH,@MONTH,@TEMPDATE)
    SELECT @DAY = DATEDIFF(DAY,@TEMPDATE,GETDATE())

    DECLARE @AGE NVARCHAR(50)
    SET @AGE = CAST( @YEAR AS nvarchar(4)) +' Years '+ cast( @MONTH as nvarchar(4))+' Months '+ cast( @DAY as nvarchar(4))+' Days Old'
    RETURN @AGE
    END

    Reply
  25. Nawaf Na says:
    3 years ago

    Great Job. Very Clear and simple.

    Reply
  26. Me Me says:
    3 years ago

    Hi venkat.
    You are great teacher.
    I learnt from your tutorials alot.
    I have your all tutorials. C sharp sql asp mvc entity framework javascript bootstrap and much more.
    I love you so much.

    Reply
  27. tushar ghude says:
    3 years ago

    Nice tutorial
    I was playing around with this example. obviously need to do all this calculation is bcoz datediff calculates when u cross the boundary of specified parameter. Now if you directly subtract 2 date times what u get is an Interval (calculated as year-month / day-time) I.e the time lapse betn 2 dates represented in one of the above format
    Let's say there is difference of 36 years 11 months 29 days 21 hrs and 46 mins betn datetime1 and datetime2 if u subtract 2 datetimes what u will get is 1936-11-29 21:46:00:000 (note: year 1900 is default value) so to get time lapse betn any 2 dates what u can do is

    SELECT ID, Name, DateOfBirth, (GETDATE()-DateOfBirth) as Interval,

    CONVERT(varchar(10), DATEDIFF(YEAR, 0,GETDATE()-DateOfBirth))+ ' Years '

    +CONVERT(varchar(10),DATEPART(MONTH,GETDATE()-DateOfBirth))+ ' Months '

    +CONVERT(varchar(10),DATEPART(DAY, GETDATE()-DateOfBirth))+ ' Days' as Age

    FROM tblEmployeeDOB

    Hope this helps

    Reply
  28. Manish Choudhari says:
    3 years ago

    Hello Venkat,

    I have database ,Date_Time , ProcessVal1, ProcessVal2, ProcessVal3 . I want to filter out data by minute and Hourly .
    For report generation function. Can you please let me know . How i can do this.

    Reply
  29. Shabbir Ali says:
    3 years ago

    Sir your tutorials are so good !! sir littly i am confuse in
    select @years=datediff(YEAR,@tepdate,GETDATE())-case when
    (month(@dob)>month(GETDATE()) or (MONTH(@dob)=MONTH(GETDATE()) and (DAY(@dob)>DAY(GETDATE()))))then 1 else 0 end
    this statement or (MONTH(@dob)=MONTH(GETDATE() … Sir why you use this.

    Reply
  30. Raphael Bernard says:
    3 years ago

    Vankat thank you despite the fact you wrote this 5 years ago and I'm a bit late you deserve congratulations and thanks for this lesson and this series, Raph.

    Reply
  31. Adenike Akinroluyo says:
    3 years ago

    Kudvenkat, you're one of the best teachers I've ever known. Simple, step by step explanation of topics. Easy to understand.
    Thanks.

    Reply
  32. Arto Kilponen says:
    3 years ago

    If you have problems understanding the DATEDIFF, keep in mind these four things:
    1) It returns as integer.
    2) It counts how many times you have to cross a line (from one year to another etc.)
    3) It doesn't care about greater accuracy than you pass in as the first parameter. Year 2017 is year 2017, no matter whether it is January first or December 31st. So between 1.1.2017 and 31.12.2017 you are in the same year, datediff in years is zero, because you are essentially passing as parameters XX.XX.2017 and XX.XX.2017. And from 31.12.2016 to 1.1.2018 you have to cross two lines (to 2017 and then to 2018), the datediff returns two.
    4) The +/- mark just tells whether you are going forward or backwards in time.

    At least for me it took a while to understand the function, but with these four points, I think it should become pretty simple.

    Reply
  33. bext la says:
    3 years ago

    Hi. it is useful. but l encounter problem with Arithmetic overflow error converting expression to data type nvarchar.
    in this case change nvarchar to int or another when create declare and set?

    Reply
  34. Yuusuf Akorede says:
    3 years ago

    EVEN THOUGH YOUR TUTORIALS ARE STILL VERY MUCH THE BEST

    Reply
  35. Yuusuf Akorede says:
    3 years ago

    I REALLY DON'T UNDERSTAND WHY AND HOW YOU WOULD SAY THIS IS SIMPLE.

    Reply
  36. Zenbaba Weldemariam says:
    3 years ago

    Brief and outstanding THANK YOU

    Reply
  37. Johnson George says:
    3 years ago

    Outstanding Sir GOD BLESS YOU

    Reply
  38. loading. m says:
    3 years ago

    Wonderful job!

    Reply

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Xem Thêm

Bạn nên khảo sát, tìm hiểu thật kỹ, so sánh để tìm được sự lựa chọn phù hợp

Hướng dẫn mua bán nhà Quận 7 dưới 3 tỷ đảm bảo chất lượng sống 

November 30, 2022
Bạn không nên mua bán đất nền Lai Châu chung sổ

5 lưu ý quan trọng khi mua đất nền Lai Châu mà bạn cần biết

October 27, 2022
Hình ảnh mua bán biệt thự quận Đống Đa 2

6 điểm cần lưu ý trước khi mua bán biệt thự quận Đống Đa

October 21, 2022
Hình ảnh chung cư Nam Từ Liêm 3

5 kinh nghiệm mua chung cư Nam Từ Liêm an toàn hữu ích

October 11, 2022
Hình ảnh bán nhà mặt phố quận Hai Bà Trưng 2

Kinh nghiệm bán nhà mặt phố quận Hai Bà Trưng

October 4, 2022
Hình ảnh mua bán nhà riêng quận đống đa 1

9 điều cần lưu ý khi mua bán nhà riêng quận Đống Đa lần đầu

September 27, 2022
  • Liên Hệ
  • Chính Sách Bảo Mật

© 2023 JNews - Premium WordPress news & magazine theme by Jegtheme.

No Result
View All Result
  • Home
  • Bất Động Sản
  • Công Nghệ
  • Luật
  • Tài Chính

© 2023 JNews - Premium WordPress news & magazine theme by Jegtheme.