Skip to content

Here is a handy little SQL Server UDF that rounds a DATETIME column to either the MINUTE, HOUR, DAY, WEEK or MONTH.

Notifications You must be signed in to change notification settings

digitalcolony/sql-server-date-scrubbing

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 

Repository files navigation

SQL Server - Date Scrubbing UDF

Here is a handy little UDF that rounds a DATETIME column to either the MINUTE, HOUR, DAY, WEEK or MONTH.

DECLARE @now AS DATETIME
SET @now = getDate()

SELECT dbo.udfDateFirst('MINUTE',@now)
SELECT dbo.udfDateFirst('HOUR',@now)
SELECT dbo.udfDateFirst('DAY',@now)
SELECT dbo.udfDateFirst('WEEK',@now)
SELECT dbo.udfDateFirst('MONTH',@now)
SELECT dbo.udfDateFirst('YEAR',@now)

created: 2002 or 2003

About

Here is a handy little SQL Server UDF that rounds a DATETIME column to either the MINUTE, HOUR, DAY, WEEK or MONTH.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages