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 |
|
AskSQLTeam
Ask SQLTeam Question
0 Posts |
Posted - 2003-11-21 : 08:03:21
|
| Ester Cohen writes "I would like to present only the Date part of the DataTime field while the field is sorted as a date field. This is hoe the Date field in the table should look 09/09/2002 01/01/2003 03/01/2003 05/06/2003 10/06/2003" |
|
|
ehorn
Master Smack Fu Yak Hacker
1632 Posts |
Posted - 2003-11-21 : 08:36:10
|
| [code]select convert(varchar(12),getdate(),101)[/code] |
 |
|
|
jsmith8858
Dr. Cross Join
7423 Posts |
Posted - 2003-11-21 : 08:45:35
|
... but still sort on the unconverted date. you don't need to sort the game way you present.Even better: Don't do a conversion at all in SQL. just return and sort by your raw date. In your PRESENTATION layer (and you actually used the word "present" ) is where you should do all formatting that doesn't affect retrieval of data.So, if you need to strip out the time for a JOIN or for a GROUP BY or something within SQL, by all means do it. But if the goal is just to make a column look good on a report, do NOT do it in SQL but rather in Excel, ASP*, Crystal Reports, Access, or however you are displaying the results.* Caveat: ASP sucks when it comes to giving you options for formatting dates unless you do it yourself. Not sure about ASP.Net. I miss the old Format() function in VB !- Jeff |
 |
|
|
|
|
|