Getting Midnight in SQL

Just a little udf that gets midnight for a datetime. CREATE FUNCTION dbo.Midnight (@Date datetime) RETURNS Datetime AS BEGIN return CAST(FLOOR(CAST(@Date AS FLOAT)) AS DATETIME) END

Parse Paths in SQL

Just a couple of udf to handle paths in sql server, not very solid but if your paths are valid they work well. CREATE FUNCTION dbo.GetFileName (@Path varchar(512)) RETURNS varchar(255) AS BEGIN Return RIGHT(@Path, LEN(@Path) – dbo.LAST_INDEX(@Path, ‘\’)) END