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 2000 Forums
 SQL Server Development (2000)
 Trim timestamp from the date object

Author  Topic 

veparala
Starting Member

30 Posts

Posted - 2010-04-21 : 16:13:12

Hi

I have a Date object with timestamp (ex: 01/01/2009 12:00:00 AM). I need to remove timestamp from the date object (like 01/01/2009).

what is the function for this?. Anybody help me.

Thanks
Venkat

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2010-04-21 : 16:17:05
This is better done in your application, but here is how to do it in T-SQL:

SELECT CONVERT(varchar(10), [date], 101)
FROM YourTable
...

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

Subscribe to my blog
Go to Top of Page

veparala
Starting Member

30 Posts

Posted - 2010-04-21 : 16:19:30
Hi

Thanks for the reply. But i don't want convert date into varchar datatype. Still i need date object after triming timestamp.
Go to Top of Page

vijayisonly
Master Smack Fu Yak Hacker

1836 Posts

Posted - 2010-04-21 : 16:24:16
Then its no longer a datetime field. The datetime fields will always have the time portion along with it.

As Tara suggested, do your formatting in your front end.
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2010-04-21 : 16:28:26
veparala, it just isn't possible in SQL Server 2000. There are three choices:

1. Use CONVERT with the appropriate style
2. Do the formatting in the presentation layer (the application receiving the data)
3. Upgrade to SQL Server 2008

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 -