Morning Everyone,

I have just started training on SQL and was wondering if you could help with a problem I have encountered.

I have populated a column with a date via the CREATE TABLE Function

USE Occupancy
CREATE TABLE Time
(Date date not null)

DECLARE @StartDate Date,
@EndDate Date

SET @StartDate = '01 Jan 2010'
SET @EndDate= '31 March 2015'
WHILE @StartDate <= @EndDate

BEGIN
INSERT INTO Time
VALUES (@StartDate)
SET @StartDate = Dateadd(dd,1,@StartDate)
END

But what I would like to do now is create 4 Extra columns called CalendarYear, CalendarMonth, FinancialYear and finally FinancialMonth, I know I should use the Datepart function but not matter how many time I have written it, it doesn't seem to work.

All help is much appreciated.

Thanks

Wayne