Different Formats of DATETIME data allowed while inserting into DATETIME type Column

Bandi
Posted by Bandi under Sql Server category on | Points: 40 | Views : 374
SET DATEFORMAT MDY
GO
CREATE TABLE X(D DATETIME)

INSERT INTO X VALUES ('19881027') --YYYYMMDD
INSERT INTO X VALUES ('881027') --YYMMDD
INSERT INTO X VALUES ('10/27/1988') --MM/DD/YYYY
INSERT INTO X VALUES ('10/27/56') -- MM/DD/YY
INSERT INTO X VALUES ('27 OCT 1988') -- DD MON YYYY
INSERT INTO X VALUES ('27 OCT 88') -- DD MON YY
INSERT INTO X VALUES ('OCT 27 1988') -- MON DD YYYY
INSERT INTO X VALUES ('OCT 27, 1988') -- MON DD, YYYY
INSERT INTO X VALUES ('OCT 27, 88') -- MON DD, YY
INSERT INTO X VALUES ('OCTOBER 27, 1988') -- MONTH DD, YYYY
SELECT * FROM X

DROP TABLE X
/*OUTPUT:
D
1988-10-27 00:00:00.000
1988-10-27 00:00:00.000
1988-10-27 00:00:00.000
1956-10-27 00:00:00.000
1988-10-27 00:00:00.000
1988-10-27 00:00:00.000
1988-10-27 00:00:00.000
1988-10-27 00:00:00.000
1988-10-27 00:00:00.000
1988-10-27 00:00:00.000
*/

Comments or Responses

Login to post response