Query comparing dates in SQL

Instead of ‘2013-04-12’ whose meaning depends on the local culture, use ‘20130412’ which is recognized as the culture invariant format. If you want to compare with December 4th, you should write ‘20131204’. If you want to compare with April 12th, you should write ‘20130412’. The article Write International Transact-SQL Statements from SQL Server’s documentation explains how to … Read more

Optimistic vs. Pessimistic locking

Optimistic Locking is a strategy where you read a record, take note of a version number (other methods to do this involve dates, timestamps or checksums/hashes) and check that the version hasn’t changed before you write the record back. When you write the record back you filter the update on the version to make sure it’s … Read more

Conversion of a varchar data type to a datetime data type resulted in an out-of-range value in SQL query

Try ISDATE() function in SQL Server. If 1, select valid date. If 0 selects invalid dates. Click here to view result EDIT : As per your update i need to extract the date only and remove the time, then you could simply use the inner CONVERT or EDIT 2 : The major reason for the error will be in your … Read more