Q

Inserting and retrieving dates in the dd/mm/yyyy HH24:mi:ss format

How do you insert or retrieve dates in the format dd/mm/yyyy HH24:mi:ss in SQL Server? Actually, I'm migrating a product from Oracle to SQL Server. The Convert function in SQL Server doesn't have a style like this and this is needed urgently. They have other styles, but I want this particular one.

To retrieve, roll your own format:

 select convert(varchar(50), getdate(),103)+' '+convert(varchar(50), getdate(),14)
To insert just ensure the DATEFORMAT is set correctly:
 create table #datetest ( datevalue datetime' ) SET DATEFORMAT DMY insert #datetest(datevalue) values('29/08/2002 21:20:03:787')

 

For More Information

This was last published in September 2002

Dig Deeper on Microsoft SQL Server Installation

PRO+

Content

Find more PRO+ content and other member only offers, here.

Have a question for an expert?

Please add a title for your question

Get answers from a TechTarget expert on whatever's puzzling you.

You will be able to add details on the next page.

Start the conversation

Send me notifications when other members comment.

By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Please create a username to comment.

-ADS BY GOOGLE

SearchBusinessAnalytics

SearchDataCenter

SearchDataManagement

SearchAWS

SearchOracle

SearchContentManagement

SearchWindowsServer

Close