Hi in sll i want sql where Condiotion submitdata 01/07/2022 to 31/03/2025 this data i want to display any one please help
year it will be chages so need to tae parameter in year column so i take current year and next year as current +1
Month(dateofsubmissstio) >=07 and year(dateofsubmissstio)=current and(between not working ) Month(dateofsubmissstio) <=03 and year(dateofsubmissstio)=next

Jayraj ChhayaRank #304 · 8.2K reputationPosted Dec 18, 2023, 1:36 AM EST
Hi Thulasiram pakala,
SELECT * FROM your_table WHERE (YEAR(dateofsubmission) = YEAR(CURRENT_DATE) OR YEAR(dateofsubmission) = YEAR(CURRENT_DATE) + 1) AND ( (MONTH(dateofsubmission) >= 7 AND YEAR(dateofsubmission) = YEAR(CURRENT_DATE)) OR (MONTH(dateofsubmission) <= 3 AND YEAR(dateofsubmission) = YEAR(CURRENT_DATE) + 1) )Naveen KumarRank #249 · 10K reputationPosted Dec 18, 2023, 9:34 AM EST
Try this
-- Directly pass start and end date --DECLARE @StartDate DATE = '2022-07-01'; --DECLARE @EndDate DATE = '2023-03-31'; --If year need to be parameterized with start of 7th month to end of 3rd month DECLARE @StartYear INT = 2022; DECLARE @EndYear INT = 2023; DECLARE @StartDate DATE = CAST(CAST(@StartYear AS VARCHAR) + '-07-01' AS DATE); DECLARE @EndDate DATE = CAST(CAST(@EndYear AS VARCHAR) + '-03-31' AS DATE); SELECT * FROM WHERE = @StartDate AND <= @EndDate;