select Count(*)
from [BV_OCM].[dbo].[TblBatch] WHERE (DisposalStatus = 17) AND (ScheduleDisposalOn BETWEEN DATEADD(day, 1, GETDATE()) AND DATEADD(day, 2, GETDATE()))
Loading
select Count(*)
from [BV_OCM].[dbo].[TblBatch] WHERE (DisposalStatus = 17) AND (ScheduleDisposalOn BETWEEN DATEADD(day, 1, GETDATE()) AND DATEADD(day, 2, GETDATE()))
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Vishal JoshiRank #377 · 6.7K reputationPosted Jun 7, 2023, 9:08 AM EDT
var batchCount = TblBatch.Where(a=> a.DisposalStatus == 17 && a.ScheduleDisposalOn > DateTime.Now.AddDays(-8) && a.ScheduleDisposalOn < DateTime.Now.AddDays(0)).Count();Vishal JoshiRank #377 · 6.7K reputationPosted Jun 7, 2023, 8:49 AM EDT
Hello
Please try the below.
var batchCount = TblBatch.Where(a=> a.DisposalStatus == 17 && a.ScheduleDisposalOn > DateTime.Now.AddDays(1) && a.ScheduleDisposalOn < DateTime.Now.AddDays(2)).Count();Thanks
Sandeep KumarRank #1,642 · 937 reputationPosted Jun 7, 2023, 8:55 AM EDT
select Count(*)
from [BV_OCM].[dbo].[TblBatch] WHERE (DisposalStatus = 17) AND (ScheduleDisposalOn BETWEEN dateadd(day,-8,GETDATE()) AND GETDATE())
Sandeep KumarRank #1,642 · 937 reputationPosted Jun 7, 2023, 9:25 AM EDT
Here >= or only >
&& a.ScheduleDisposalOn > DateTime.Now.AddDays(-8)
Vishal JoshiRank #377 · 6.7K reputationPosted Jun 8, 2023, 3:29 AM EDT
Yes if you are expecting data for the same day then need it requires >= and for toDate it requires <=