View Single Post
  #5 (permalink)  
Old March 1st, 2006, 11:25 AM
rgerald rgerald is offline
Friend of Wrox
 
Join Date: Jun 2003
Location: Naperville, IL, USA.
Posts: 196
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I just tested my function - described earlier with varchar(10) data. It works!!!

Code:
IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = object_id(N'[t_Date3]') AND OBJECTPROPERTY(id, N'IsUserTable') = 1)
DROP TABLE [t_Date3]
GO

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = object_id(N'[dbo].[t_Date3]') AND OBJECTPROPERTY(id, N'IsUserTable') = 1)
 BEGIN
CREATE TABLE [t_Date3] (
    [ID] [int] identity NOT NULL ,
    [Date3] varchar(10) NULL 
) ON [PRIMARY]
END

GO

INSERT INTO [RandTest].[dbo].[t_Date3]([Date3])
VALUES('01/01/2001')

INSERT INTO [RandTest].[dbo].[t_Date3]([Date3])
VALUES('02/29/2004')

INSERT INTO [RandTest].[dbo].[t_Date3]([Date3])
VALUES('03/01/2004')

INSERT INTO [RandTest].[dbo].[t_Date3]([Date3])
VALUES('03/02/2004')

INSERT INTO [RandTest].[dbo].[t_Date3]([Date3])
VALUES('03/01/2000')

INSERT INTO [RandTest].[dbo].[t_Date3]([Date3])
VALUES('12/31/1999')

INSERT INTO [RandTest].[dbo].[t_Date3]([Date3])
VALUES('04/01/2003')

INSERT INTO [RandTest].[dbo].[t_Date3]([Date3])
VALUES('02/07/1998')

INSERT INTO [RandTest].[dbo].[t_Date3]([Date3])
VALUES('12/24/1937')

INSERT INTO [RandTest].[dbo].[t_Date3]([Date3])
VALUES('05/08/1948')

INSERT INTO [RandTest].[dbo].[t_Date3]([Date3])
VALUES('03/03/2003')

INSERT INTO [RandTest].[dbo].[t_Date3]([Date3])
VALUES('02/29/1960')
GO

SELECT [ID], [Date3] [Birth Date], dbo.f_AgeCalc([Date3], GetDate()) [Age] FROM [RandTest].[dbo].[t_Date3]
GO
Rand
Reply With Quote