-- The SMALLDATETIME data type specifies a date and time of day in SQL Server.
-- SMALLDATETIME supports dates from 1900-01-01 through 2079-06-06.
-- The default value is 1900-01-01 00:00:00.
--The seconds are always set to 0, and fractional seconds are not included.
-- EXAMPLE
CREATE TABLE DemoTable
(
Id INT IDENTITY,
ProductName VARCHAR(100) NOT NULL,
RestockDate SMALLDATETIME
);
GO
INSERT INTO DemoTable VALUES ('Lays Chips', '2021-02-15 9:55:12');
INSERT INTO DemoTable VALUES ('Quaker Oats', '2021/11/08 8AM');
INSERT INTO DemoTable VALUES ('Oreo Cookies', '2021-05-14 13:12');
INSERT INTO DemoTable VALUES ('Fritos', '2021-9-2');
INSERT INTO DemoTable VALUES ('Cheetos', NULL);
GO
SELECT * FROM DemoTable;
GO
DROP TABLE DemoTable;
GO
Results: 5 records
ID PRODUCTNAME RESTOCKDATE
1 Lays Potato Chips 2021-02-15 09:55:00
2 Quaker Oats 2021-11-08 08:00:00
3 Oreo Cookies 2021-05-14 13:12:00
4 Fritos 2021-09-02 00:00:00
5 Cheetos NULL
-- Notice how SQL Server accepts different input date and time formats.
-- These formats are converted to the internal format which is 'YYYY-MM-DD HH:MM:00'.
The SMALLDATETIME data type specifies a date and time of day in SQL Server. SMALLDATETIME supports dates from 1900-01-01 through 2079-06-06. The default value is 1900-01-01 00:00:00. The seconds are always set to 0, and fractional seconds are not included.