Search
 
SCRIPT & CODE EXAMPLE
 

SQL

SQL SMALLDATETIME Data Type

-- 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'.


Comment

smalldatetime in sql

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.
Comment

PREVIOUS NEXT
Code Example
Sql :: tsql utf to local time 
Sql :: sql id serial primary key 
Sql :: can pandas fetch data from sql 
Sql :: find employee with max salary sql 
Sql :: guid string to binary better 
Sql :: criteria builder select subset of column 
Sql :: sql server isnull function nor working count 
Csharp :: dotnet install ef 
Csharp :: vb.net messagebox yes no cancel 
Csharp :: c# hello world program 
Csharp :: c# char input 
Csharp :: c# get username 
Csharp :: draw sphere gizmo unity 
Csharp :: check if gameobject is active 
Csharp :: How to read SQL Server COUNT from SqlDataReader 
Csharp :: c# get file size in bytes 
Csharp :: c# center text 
Csharp :: unity set object scale 
Csharp :: c# linq extension methods left join 
Csharp :: clone gameobject unity c# 
Csharp :: unity textmeshpro 
Csharp :: c# copy to clipboard 
Csharp :: csharp string to double 
Csharp :: unity get current scene 
Csharp :: random value in array c# 
Csharp :: unity get gameobject script is attached to 
Csharp :: how to change the extension of a file C# 
Csharp :: unity stop all audio 
Csharp :: c# round to 2 decimal places 
Csharp :: how to check if list index is out of range in c# 
ADD CONTENT
Topic
Content
Source link
Name
6+2 =