For example, you may have today’s datetime (2011-10-10 20:30:28.230) and you want to only get the following value: 2011-10-10.
A typical example is the following:
However, in earlier versions of SQL Server the DATE type is not available.
So, if you have a SQL Server 2005 instance or earlier and you want to get the date value from a datetime value you can just create and use a simple scalar-valued function like the following:
Now that the function is created, the first example changes to:
…. and that’s it! 🙂
I hope you found the article useful!
Until next time!
My Latest Projects:
- DBA Security Advisor: Secure your SQL Server instances against security risks.
- In-Memory OLTP Simulator: Easily benchmark SQL Server’s In-Memory OLTP Engine against your custom workload.
- Artemiou SQL Books: Download my latest free books on SQL Server.
- Artemiou Data Tools: See my latest software projects.
Recommended eBooks on SQL Server: