Created
June 1, 2015 21:09
-
-
Save clintmjohnson/c992ab4f21602cf3a15f to your computer and use it in GitHub Desktop.
Convert MMDDYYYY to SQL Server Date Type Function
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| CREATE FUNCTION [dbo].[MMDDYYYY_TO_SQL_DATE] | |
| ( | |
| @MMDDYYYY char(8) | |
| ) | |
| RETURNS date | |
| AS | |
| BEGIN | |
| DECLARE @date_out date | |
| SET @date_out = CAST(RIGHT(@MMDDYYYY,4)+'-'+LEFT(@MMDDYYYY,2)+'-'+SUBSTRING(@MMDDYYYY,3,2) as date) | |
| RETURN @date_out | |
| END |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment