Click here to Skip to main content
15,868,419 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am using this query to get the record

 SELECT TOP(12) mm.MeetingMasterId, mm.MeetingId, mm.MeetingName, mm.MeetingDate
,mm.MeetingStatus
,mm.MeetingThumbnail
FROM Videofono_MeetingMaster mm  WHERE mm.PortalId=0
AND  MeetingStatus IN ('Finish')
AND 
mm.MeetingMasterId in (SELECT dbo.Videofono_MeetingMaster.MeetingMasterId
FROM  dbo.Videofono_MeetingMaster INNER JOIN
dbo.Videofono_ArgumentDetailMaster ON dbo.Videofono_MeetingMaster.MeetingMasterId = dbo.Videofono_ArgumentDetailMaster.MeetingMasterId INNER JOIN
dbo.Videofono_ArgumentMaster ON dbo.Videofono_ArgumentMaster.MeetingMasterId = dbo.Videofono_MeetingMaster.MeetingMasterId INNER JOIN
dbo.Videofono_CouncilorMaster ON dbo.Videofono_ArgumentDetailMaster.CouncilorMasterId = dbo.Videofono_CouncilorMaster.CouncilorMasterId INNER JOIN
dbo.Videofono_CategoryMaster ON dbo.Videofono_CouncilorMaster.CategoryId = dbo.Videofono_CategoryMaster.CategoryId
WHERE 
(dbo.Videofono_CouncilorMaster.CouncilorName = case when 'null' is null then dbo.Videofono_CouncilorMaster.CouncilorName else  'null' end)
 AND (Convert(date,dbo.Videofono_MeetingMaster.MeetingDate,103) >=case when '2017-10-25' is null then convert(date, dbo.Videofono_MeetingMaster.MeetingDate,103) else  CONVERT(DATE, '2017-10-25', 103) end)
 AND  (Convert(date,dbo.Videofono_MeetingMaster.MeetingDate,103) <=case when '2017-11-13' is null then convert(date, dbo.Videofono_MeetingMaster.MeetingDate,103) else  CONVERT(DATE, '2017-11-13', 103) end)
 AND (dbo.Videofono_CategoryMaster.CategoryName =case when 'null' is null then  dbo.Videofono_CategoryMaster.CategoryName else  'null' end) 
 AND (dbo.Videofono_MeetingMaster.PortalId =0))
 ORDER BY mm.MeetingMasterId DESC


Please help me in this moment, because my work has been stopped by this.
your help will be appreciated.

What I have tried:

I tried with CONVERT and DATETIME2
Posted
Updated 25-Dec-17 22:08pm
v2

1 solution

Somewhere in there - and I don't see where - there is a string based date being converted to a DATE, DATETIME, or DATETIME2 column, and the data in the string is not a valid date, or is in the wrong format for the server the SQL instance is running on to understand.

Simple solution: stop storing date info as strings and always store it as DATE, DATETIME, or DATETIME2 so SQL doesn't have to try and work out what format the date info is in as it always gives problems.

But that code is weird - you are comparing fixed strings to null and that will succeed, a string cannot be null:
case when '2017-10-25' is null then
So either the code you show us is not what you are actually executing, or that code is ... um ... different and unusual

I'd start by looking at my columns, and at what code you used to generate that query, if any.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900