Hi friends
I want to know that how to work with date\time data in SQL Server. Please explain it with example.
Thank you.
Work with Date\Time Data in SQL Server
2 Answers
Know the answer? Post it. Somebody with the same question will find it here.


SenthilkumarRank #387 · 6.5K reputationPosted Apr 18, 2012, 6:45 PM EDT
The Date and Time was same data type in earlier versions of sql server.
But in sql server 2008 onwards the date and time can be splitted.
usually when you create the sql server table
postedDate DATETIME DEFAULT GETDATE()
If you want to convert the date format then
SELECT CONVERT(VARCHAR,dPostedDate,108)
It will convert into the required format.
Similarly if you want to customize the date and time format then see the table in the below link
http://www.blackwasp.co.uk/SQLDateTimeFormats.aspx
If you want to know about the Date and Time data types in sql server 2008 then
http://www.mssqltips.com/sqlservertip/1616/sql-server-2008-date-and-time-data-types/
Jignesh TrivediRank #16 · 50.3K reputationPosted Apr 18, 2012, 7:46 PM EDT
In SQL Server - 2008 has many datetime datatype, like time, date, datetime2 and datetimeoffset and also support older dataa type like smalldatetime etc.
now datetime use in sql just like datetime in c#
but import is what is actual requirement.
hope this help.