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.
| Author |
Topic |
|
jennypretty
Yak Posting Veteran
96 Posts |
Posted - 2005-04-18 : 10:59:07
|
| Hello friends,I have a table like this:empname hiredate------------------john 1999-02-03 00:00:00.000How do I get rid of all the zero from hiredate? I want to show the year month and date only on that field.Thanks,Jenny.The stupid question is the question you don't ask.www.single123.com |
|
|
DonAtWork
Master Smack Fu Yak Hacker
2167 Posts |
Posted - 2005-04-18 : 11:09:32
|
| Don't confuse data storage with presentation. Let the client deal with formatting the data.Anyway, to give them the data without the time (i got this script from this site somewhere)SELECT dateadd(dd,datediff(dd,0,[DateTime Column Name]),0) as DateOnly from TblTableName |
 |
|
|
jsmith8858
Dr. Cross Join
7423 Posts |
Posted - 2005-04-18 : 11:18:08
|
| great advice, Don. Never confuse formatting the data with the data itself. How are you presenting the result of this SELECT to your users? on a web page? a report? Excel? That is where the formatting should occur.Remember, in SQL, when you "format", you are just converting things to varchars and you are no longer dealing with true dates or numbers. And you have seen several times already what happens if you format things as text and then try to sort or filter -- it doesn't work. Right?- Jeff |
 |
|
|
jennypretty
Yak Posting Veteran
96 Posts |
Posted - 2005-04-18 : 11:25:41
|
| Ok. It reminded me of my last posts.Thanks.Jenny.The stupid question is the question you don't ask.www.single123.com |
 |
|
|
|
|
|