Permanent Solution to an old Problem
One of the rare issues came up today where I need to extract the date only from a datetime field.
I remembered part of it but still had to google for a second to get the other pieces. Now, I'm posting the syntax here so I don't have to go hunting for it later.
Bottom Line:
The reason this is becoming an issue is the App this db serves is a thirdparty app so I'm going to not have much success in making changes. I''m thinking about a insert trigger to all the system to cleanup the data going in and store the time records in another field.
Ben Nadel has a copy of posts up about this: Ask Ben: Getting Only the Date Part of a Date/Time Stamp in SQL Server
And then he follows that up with this little beauty, Ask Ben: Comparing Only Times in SQL
The Truth is out there.
