GoDaddy Website Builder for $1/Mo.!

Adbrite

Tuesday, June 24, 2008

Minimum year value in SQL server 2008(date data type)

Minimum year value in SQL server 2008(date data type)

SQL server 2008 comes with lots of new features and they separated SQL server datetime data type as Date and Time (datetime data type also available).SQL server previous versions (SQL 2000, SQL 2005) there is limit for min date (year-1753) and max date (year-9999). But when you notice SQL server 2008 date data type min date is 0001.



/*
Date 24/06/2008
SQL SERVER 2000 and 2005
*/
DROP TABLE dateCheck;
CREATE TABLE dateCheck(dateCol datetime);
GO
--can
INSERT INTO dateCheck(dateCol) VALUES ('12/31/1753')
GO
--can't
INSERT INTO dateCheck(dateCol) VALUES ('01/01/1752')
GO
SELECT * FROM dateCheck
GO

/*
Date 24/06/2008
SQL SERVER 2008
*/
--datetime data type
DROP TABLE dateCheckDateTime;
CREATE TABLE dateCheck(dateCol datetime);
GO
--can
INSERT INTO dateCheck(dateCol) VALUES ('12/31/1753');
--can't
INSERT INTO dateCheck(dateCol) VALUES ('01/01/1752');
GO
SELECT * FROM dateCheck;
GO
--date data type
DROP TABLE dateCheckDate;
CREATE TABLE dateCheckDate(dateCol date);
GO
--can
INSERT INTO dateCheckDate(dateCol) VALUES ('01/01/1753');
INSERT INTO dateCheckDate(dateCol) VALUES ('01/01/1752');
INSERT INTO dateCheckDate(dateCol) VALUES ('01/01/0001');
GO
SELECT * FROM dateCheckDate;
GO

7 comments:

Anonymous said...

Ideal variant

Anonymous said...

Your blog keeps getting better and better! Your older articles are not as good as newer ones you have a lot more creativity and originality now keep it up!

Anonymous said...

Good fill someone in on and this mail helped me alot in my college assignement. Thank you for your information.

Anonymous said...

Good post and this enter helped me alot in my college assignement. Say thank you you on your information.

Anonymous said...

Nice dispatch and this fill someone in on helped me alot in my college assignement. Thank you seeking your information.

The Genius said...

It's cool that the earliest date has changed to 0001, because that arbitrary 1753 business was crazy. So, how can you detect if your code is writing to Sql Server 2008? We have sites where the database is unknown to the code.

generic cialis said...

I, of course, a newcomer to this blog, but the author does not agree