Created
January 2, 2018 16:19
-
-
Save codenamejason/af076d6a0e9b6a626df5f41ad3d6aac7 to your computer and use it in GitHub Desktop.
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 Int2Time(@Time varchar(10), @amPM char(1)) | |
| -- returns a dateTime value for the date and time specified. | |
| -- expects a 'numeric' value for time...will excuse any characters | |
| RETURNS SMALLDATETIME | |
| AS | |
| BEGIN | |
| DECLARE @vTime AS VARCHAR(4), @Hour AS VARCHAR(2), @Minute AS VARCHAR(2) | |
| SET @vTime = RIGHT('0'+CAST(dbo.Digits(@Time) AS VARCHAR(4)),4) | |
| SET @Hour = SUBSTRING(@vTime, 1, 2) | |
| if @amPM = 'P' and @Hour < 12 | |
| set @Hour = @Hour + 12 | |
| SET @Minute = SUBSTRING(@vTime, 3, 2) | |
| RETURN DATEADD(ss,(@Hour*3600)+(@Minute*60), 0) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment