I'm creating a simple query, a simple select like
select x,y,z from etc etc but in the software, there are
start date and
If the user fills in only the first date, then it will use a
where clause like this:
where.... and... and x.date >= Startdate
If the user fills in both dates, it will use:
where.... and... and x.date between @Startdate and @enddate
If the user fills in only end date:
where.... and... and x.date < @enddate
I'm getting a syntax error with everything I'm trying to do.
where.... and... case when @startdate is not null and @enddate is null and x.date >= Startdate
Or even using
if. What is the correct syntax for this? Or this is something programmers need to fix inside the software's code?