Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 Datetime Manipulations Sqlserver 2005

Author  Topic 

aditya2010
Starting Member

10 Posts

Posted - 2010-04-26 : 19:42:08
Hi,
I want to insert datetime into a table.The value should look like
27/04/2010 00:00:00

I want the time part but it should be 00:00:00.
Help me to get this value.

Thanks.

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2010-04-26 : 19:49:49
Here's an example: SELECT DATEADD(Day, DATEDIFF(Day, 0, GETDATE()), 0)

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page

aditya2010
Starting Member

10 Posts

Posted - 2010-04-26 : 19:59:00
Hi,thanks for replying.Can i get that date to dd/mm/yyyy format instead yyyy/mm/dd?
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2010-04-26 : 20:05:15
It's not actually stored in either of those formats. If you want to display the data differently than the default display, then the formatting should happen in your application. You could use the CONVERT function with the appropriate style (see BOL for the chart) if you need to do it in T-SQL, but formatting data for display purposes is best done in the presentation layer (the application).

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page

aditya2010
Starting Member

10 Posts

Posted - 2010-04-26 : 20:15:33
Thanks.That worked.
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2010-04-26 : 20:21:14
You're welcome.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page
   

- Advertisement -