SQL Query | Calculate number of weekdays between two dates | Exclude Weekends | DateDiff | DateName

  Рет қаралды 53,563

Learn at Knowstar

Learn at Knowstar

Күн бұрын

Пікірлер: 72
@hv0032113
@hv0032113 4 жыл бұрын
Very helpful. Best compilation for sql queries.
@LearnatKnowstar
@LearnatKnowstar 4 жыл бұрын
Thank you
@Beyondhorizons-i5z
@Beyondhorizons-i5z 4 жыл бұрын
Thank you. Very helpful to prepare for the interviews.
@LearnatKnowstar
@LearnatKnowstar 4 жыл бұрын
Thank you
@razrolfTV
@razrolfTV 2 жыл бұрын
Thank you very much! The video was extremly helpful. Bravo. I was exactly looking for the same material as explained. Hands down. 🙌
@LearnatKnowstar
@LearnatKnowstar 2 жыл бұрын
Glad it was helpful 🙏
@kingsleyarisah6354
@kingsleyarisah6354 Ай бұрын
Great content
@LearnatKnowstar
@LearnatKnowstar Ай бұрын
Thank You!
@avinashc8146
@avinashc8146 3 жыл бұрын
Thank you so much for videos it was simply superb
@LearnatKnowstar
@LearnatKnowstar 3 жыл бұрын
Thank you
@fabifs07
@fabifs07 3 жыл бұрын
Thanks a lot, Really helpful my life today.
@LearnatKnowstar
@LearnatKnowstar 3 жыл бұрын
Thanks so much!
@mahesh84
@mahesh84 3 жыл бұрын
thank you.. this video solved my problem in code :)
@LearnatKnowstar
@LearnatKnowstar 3 жыл бұрын
Thank you
@sahameed
@sahameed 2 жыл бұрын
Great , Many Thanks. 👍
@LearnatKnowstar
@LearnatKnowstar 2 жыл бұрын
Thank you
@viniciusluiz8833
@viniciusluiz8833 3 жыл бұрын
Very useful!
@LearnatKnowstar
@LearnatKnowstar 3 жыл бұрын
Thank you
@kristyowens2284
@kristyowens2284 3 жыл бұрын
This is really very helpful.
@LearnatKnowstar
@LearnatKnowstar 3 жыл бұрын
Thank you
@prashantbhalla3030
@prashantbhalla3030 3 жыл бұрын
Thanks a lot ❤️, saved my day 👍
@LearnatKnowstar
@LearnatKnowstar 3 жыл бұрын
Thank you
@TwoUpProductions
@TwoUpProductions 3 жыл бұрын
Very helpful. Thank you so much!
@LearnatKnowstar
@LearnatKnowstar 3 жыл бұрын
Thank you
@sachingulati9857
@sachingulati9857 Жыл бұрын
Thanks for explaining the concept in such an easy way, However i wanna ask a question: Suppose the orderdate is on saturday or sunday and the delivery day is also same. What do we do in this scenario?
@sidmylifemyrules
@sidmylifemyrules 3 жыл бұрын
Thanks a lottttt!!!! Really helpful.
@LearnatKnowstar
@LearnatKnowstar 3 жыл бұрын
Thank you!
@lianyiwang3209
@lianyiwang3209 2 жыл бұрын
Hi, could you explain why not consider both order date on Saturday and Sunday as 1, else 0? Same question on ship date
@CaribouDataScience
@CaribouDataScience Жыл бұрын
Thanks
@imranpathan8352
@imranpathan8352 3 жыл бұрын
Nice video mam.. please provide database to work
@rahulganga3274
@rahulganga3274 Жыл бұрын
Super mam your are Great 👍 👌 😀
@LearnatKnowstar
@LearnatKnowstar Жыл бұрын
Glad it was helpful.
@rahulganga3274
@rahulganga3274 Жыл бұрын
Great 👍
@LearnatKnowstar
@LearnatKnowstar Жыл бұрын
Glad it was helpful!
@ramakrishnasamala4201
@ramakrishnasamala4201 3 жыл бұрын
well explained
@LearnatKnowstar
@LearnatKnowstar 3 жыл бұрын
Thank you
@surajpatil3579
@surajpatil3579 3 жыл бұрын
Thank you for this
@somiyasaxena1419
@somiyasaxena1419 Жыл бұрын
Hello Ma'am, I really appreciate your work, it's like free videos, and I will learn these things but the biggest problem with me is I'm unable to do it, whether the intermediate course or advanced course. I'm so frustrated that in the end, I will see the answer. I've seen so many videos but I'm unable to do it myself. what to do? is it like for others or it's just with me?
@LearnatKnowstar
@LearnatKnowstar Жыл бұрын
Thank you. Try to keep practicing with the datasets provided in the videos. Even after seeing the result, try to write the same query yourself again. If you keep practicing, you will soon learn the tricks to solve these queries. But the key is to write the query yourself every time you watch a video. Hope it helps 👍
@lingxu9697
@lingxu9697 2 жыл бұрын
Is it easier to use a case and count for this scenario?
@jayantirawat8623
@jayantirawat8623 Жыл бұрын
Can I get this table create statement and select statement query
@theduck72
@theduck72 Жыл бұрын
Nice
@LearnatKnowstar
@LearnatKnowstar Жыл бұрын
Thanks
@avinashc8146
@avinashc8146 3 жыл бұрын
And ma'am can we get any place where we can interact with you
@LearnatKnowstar
@LearnatKnowstar 3 жыл бұрын
You can always post your queries on our KZbin channel
@Farhazh
@Farhazh 3 жыл бұрын
Thank you soo much very helpful! Just one question where i am stuck from couple of days and not getting a solution. Here by default sql server considers weekend as saturday and sunday, what if i need to calculate no. Of days between 2 dates considering weekend as friday? Request you to kindly help me with the code. Thanks :)
@LearnatKnowstar
@LearnatKnowstar 3 жыл бұрын
Thank you. In this case, you would need to use a Calendar table that identifies the Friday as a holiday. You can then identify the working days and calculate accordingly.
@Farhazh
@Farhazh 3 жыл бұрын
@@LearnatKnowstar thank you for the prompt response! Was just wondering if you care to explain more about how to progress on it..
@asmitap1863
@asmitap1863 3 жыл бұрын
Is there a way to execute this in Impala/Hive?
@LuckyK
@LuckyK 4 жыл бұрын
thank you. what about Holidays ? what if you have a Date table and also exclude Holidays
@LearnatKnowstar
@LearnatKnowstar 4 жыл бұрын
Having a date table that marks weekends and holidays makes it much easier to implement this requirement as a simple join can determine whether the day is a work day or not.
@alsonncube5831
@alsonncube5831 4 жыл бұрын
@@LearnatKnowstar Is it possible to do it without the date table?
@LearnatKnowstar
@LearnatKnowstar 4 жыл бұрын
It is possible though not the preferred way.
@LearnatKnowstar
@LearnatKnowstar 4 жыл бұрын
You will need to write a function that identifies the holidays.either by constant dates for ex Christmas always falls on 25th Dec or holidays that fall on a particular day of a week..for ex every 1st Monday of August etc.
@vibhanshudongre
@vibhanshudongre 3 жыл бұрын
Can you let us know from where we can download these databases for practice ?
@LearnatKnowstar
@LearnatKnowstar 3 жыл бұрын
You can download sample databases. You can refer this video tutorial - kzbin.info/www/bejne/pJTNYXh6r96SqNk
@Avengers.119
@Avengers.119 4 жыл бұрын
I need training on data stage with SQL,please provide your contract information
@LearnatKnowstar
@LearnatKnowstar 4 жыл бұрын
We will be announcing the batches soon on our KZbin channel. Stay tuned.
@ngneerin
@ngneerin 2 жыл бұрын
Will work incorrectly if order date is 2015-01-11 and ship date is 2015-01-25
@sidmishra8252
@sidmishra8252 2 жыл бұрын
But like from 11 to 24 you have 2 Sunday and 2 Saturday. So, you should take it as total 4 off days
@KajalSharma16
@KajalSharma16 3 жыл бұрын
It is not working for TEradata (datediff function)
@KajalSharma16
@KajalSharma16 3 жыл бұрын
ALTER TABLE mytable ADD difference_dt as DATEDIFF(DAY, start_dt, end_DT ) ; gives an error "Syntax error, expected something like a 'TRANSACTIONTIME' keyword between the 'as' keyword and the word 'DATEDIFF'." or SELECT DATEDIFF(day, start_dt, end_DT) as difference FROM mytable gives error "Syntax error: expected something between '(' and the 'day' keyword." kindly let me know
@LearnatKnowstar
@LearnatKnowstar 3 жыл бұрын
Datediff function is not a valid teradata function. You will need to subtract two days to get the difference. You can refer here docs.teradata.com/r/1DcoER_KpnGTfgPinRAFUw/WdO2taOuHi5IaUk0dEsJTg
@zainabghassan632
@zainabghassan632 2 жыл бұрын
How can we find days between different dates in one column based on user id?
@MangeshBarhatemyav
@MangeshBarhatemyav 2 жыл бұрын
How calculate last week of year date - next year any date first week date . I tried
@nehakaw7685
@nehakaw7685 2 жыл бұрын
How to calculate if we only need to skip a Sunday and want to consider monday to saturday as weekdays
@landchennai8549
@landchennai8549 25 күн бұрын
alter function ufn_getweekdaysbetweentwodate(@StartDate Datetime, @EndDate datetime) returns int as begin declare @Cnt int select @Cnt = count(1) from generate_series(0,datediff(dd,@StartDate, @EndDate) -1,1) where Datename(dw, @StartDate +Value) not in ('Saturday','Sunday') return @Cnt end declare @StartDate datetime = getdate(), @EndDate datetime = getdate() +10 select @StartDate as StartDate, @EndDate as EndDate,dbo.ufn_getweekdaysbetweentwodate (@StartDate,@EndDate) as WeekDaysbwtwodates
@ishitvasingh9902
@ishitvasingh9902 Жыл бұрын
I have a doubt, in your final querie's 3rd line of code, if we could have added +1 , would it work? seelct orderdate, shipdate, (datediff(dd, order, shipdate) +1) - ((datediff (ww, orderdate, shipdate) * 2 ) + 1) from sales would it work ? Please do answer
@upanshukumar7472
@upanshukumar7472 Жыл бұрын
Mam plz explain in hindi also
@LearnatKnowstar
@LearnatKnowstar Жыл бұрын
Thank you. Will try to do some Hindi videos in the future 👍
@danieljust295
@danieljust295 2 жыл бұрын
This is not working solution, works conditionally only.
SQL Query - Convert data from Rows to Columns | Pivot
4:56
Learn at Knowstar
Рет қаралды 191 М.
SQL tutorial | Date Functions | Difference between DATEDIFF and DATEADD
19:25
When mom gets home, but you're in rollerblades.
00:40
Daniel LaBelle
Рет қаралды 80 МЛН
黑的奸计得逞 #古风
00:24
Black and white double fury
Рет қаралды 28 МЛН
SQL Query | How to calculate YTD and MTD totals | Window Functions
16:01
Learn at Knowstar
Рет қаралды 42 М.
SQL Query | How to dynamically convert rows into columns | Dynamic Pivot
16:18
When mom gets home, but you're in rollerblades.
00:40
Daniel LaBelle
Рет қаралды 80 МЛН