Programming in MS SQL Server 2012

Date Time Data Type



Datetime data type is used to stores date or time or datetime information. SQL Server allows traditional and non-traditional date format. The following example describes a typical DateTime Data Type.

-- Example 77 --

 

DECLARE @ProductExpiryDate DateTime,

        @ServerSystemDate DateTime

SET @ProductExpiryDate = '12/31/2005'

SET @ServerSystemDate = GETDATE()

SELECT 'Product Expiry Date' = @ProductExpiryDate,

       'Server System Date' = @ServerSystemDate,

       'Date Different Data' = DATEDIFF(Day, @ProductExpiryDate, @ServerSystemDate)


Query Output Screen

More Reference URL: https://data-e-education.com/SQL/Date_And_Time_Data_Types.php

* * * * *


Email Your Comment To AUTHOR