I have a database that stores its dates as a number in a YYYYMMDD format. I have created a function to convert this to a real date, however the function fails if the date is zero or NULL. Here is the function:
Any idea what I can do to get this to return a date of say 1/1/1900 is the database value is zero or Null?
Software Sales, Training, Implementation and Support for Macola, Synergy, and Crystal Reports. Check out our Macola tools:
Code:
CREATE FUNCTION RealDate (@date_in INT)
RETURNS datetime
AS
BEGIN
DECLARE @date_out datetime
SET @date_out = CONVERT(datetime, CAST(@date_in AS CHAR(8)), 101)
RETURN @date_out
END
GO
Any idea what I can do to get this to return a date of say 1/1/1900 is the database value is zero or Null?
Software Sales, Training, Implementation and Support for Macola, Synergy, and Crystal Reports. Check out our Macola tools: