Google-sovellukset
Päävalikko

Post a Comment On: mo.notono.us

"SQL: Updated IsSmallDate function"

2 Comments -

1 – 2 of 2
Anonymous Anonymous said...

this script will not work correct! because, it execute correctly this datetime (exp. 01.01.1888). but, this exemple is not the smalldatetime !!
i want correct them, i modified this script on follow :

--Checks if a string is a valid smalldatetime
ALTER FUNCTION dbo.IsSmallDate
(
@SmallDateString varchar(20) --The input string to check
)
RETURNS BIT
AS
BEGIN
DECLARE @Result bit
SET @SmallDateString = LTRIM(RTRIM(@SmallDateString))

if (isdate(@SmallDateString)=1 and (year(convert(datetime, @SmallDateString)) between 1900 and 2079))
SET @Result = 1
ELSE
SET @Result = 0
END
RETURN @Result
END

Monday, April 03, 2006 4:05:00 AM

Blogger Oskar Austegard said...

Mounir, thanks.

My original code was quite brain-dead - after my struggles with ISNUMERIC I had been fixating on dates that contained year-info only.

The corrected function can be found here and also on Code Snippets.

Thanks again for correcting my bug.

Monday, April 03, 2006 10:15:00 AM

You can use some HTML tags, such as <b>, <i>, <a>

Comments on this blog are restricted to team members.

You will be asked to sign in after submitting your comment.
Please prove you're not a robot