Hi friends
I want to know that how to work with date\time data in SQL Server. Please explain it with example.
Thank you.
Loading
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Jignesh TrivediPosted Apr 18, 2012, 11:46 PM
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.
SenthilkumarPosted Apr 18, 2012, 10:45 PM
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/