Get a date part from a datetime type value in MS SQL Server.

Girl fuck Microsoft

Fuck ¬†Microsoft, don’t know why they make this job “get the date/month/year part from a datime value” become so complicate. In MySQL just use Date(datetime_value) but here we go with Microsoft SQL (work with SQL 2008 and higher)


For example, get the today date from field PostTime has data type datetime you should go:

SELECT * FROM DB_NAME WHERE Convert(Varchar(10), PostTime,111)=’2015/04/07′

This is working method, there is another way with DATEADD(), DATEDIFF() and people said that method give better performance but I don’t want to give a fuck, I wan’t something sort and work.

Finally, fuck Microsoft as usual!

Pee on Microsoft sign