Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Find rows with inv_dates
Message
From
01/05/2017 19:40:17
 
General information
Forum:
Microsoft SQL Server
Category:
SQL syntax
Miscellaneous
Thread ID:
01650725
Message ID:
01650758
Views:
46
>>>Bill,
>>>
>>>SQL Server will cache your query for better repeat performance if you use parameters rather than concatenating start and end dates into a query every time.
>>>
>>>So if your app can convert year,month,day to a start_date/end_date (watching out for minutes and seconds if it's a datetime field) and use those as BETWEEN parameters, that's very readable and is independent of database version.
>>>
>>>Or you could pass all the values to be CAST as dates in your query or via a stored procedure. Depending what language you're using (C#?) IMHO it can be more readable and easier to maintain if you assemble the dates at the app end for use as SQL parameters.
>>
>>John
>>
>>It's C#
>>I tried your method for a few hours - mainly because of the readability to you mention- and then decided to use Martina's approach.
>>The minutes on datetimes drive me nuts when trying to query dates, so I use month, day and year where I can.
>>I don't think DB version will be an issue with that technique.
>
>If you're using SQL 2012 and up and can guarantee that, then I suggest to try my version as simpler one.

I can't be sure that the user won't be using 2008
Anyone who does not go overboard- deserves to.
Malcolm Forbes, Sr.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform