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
 SQL Server Administration (2005)
 Field Formatting

Author  Topic 

rcr69er
Constraint Violating Yak Guru

327 Posts

Posted - 2008-04-24 : 07:48:46
Hi

Is there a way to format a field in a table with a datetime data type to show just the date?
ie. 24/04/2008 17:25:00 would just become 24/04/2008.

Even showing 24/04/2008 00:00:00 would be helpful.

Thanks

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2008-04-24 : 08:54:50
select dateadd(day,datediff(day,0,col),0) from your_table

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

rcr69er
Constraint Violating Yak Guru

327 Posts

Posted - 2008-04-24 : 09:00:45
Hi

What about when inserting data into the field?

Thanks
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2008-04-24 : 10:30:48

Insert into table(datecol)
select dateadd(day,datediff(day,0,getdate()),0)

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

rcr69er
Constraint Violating Yak Guru

327 Posts

Posted - 2008-04-24 : 10:48:16
Hey, Thanks for that!!!
Go to Top of Page
   

- Advertisement -