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 |
|
ronmc
Starting Member
12 Posts |
Posted - 2006-03-30 : 13:57:45
|
| We have a fairly large application that has been converted from the DOS days and is now running on SQL. In our application, we will get data from the server by running a stored procedure or a pass-through statement and get any date-time field back by doing something like:convert(varchar,oadata.date_, 101) as date_This is ok for removing the time (which we don't always want to display to the user), but when we put this data into a grid, we allow the user to sort by any column. Of course, since we converted the date into a string, it sorts as a string. This is not good when dates span years.Is there any way to bring back just the date from SQL, without having to convert it to a string?I know that the presentation layer should handle this, but our specific language does not handle it very well.Any takers? |
|
|
Michael Valentine Jones
Yak DBA Kernel (pronounced Colonel)
7020 Posts |
Posted - 2006-03-30 : 14:08:02
|
This will set the time to 00:00:00.000 (midnight):dateadd(dd,datediff(dd,0,MyDate),0) CODO ERGO SUM |
 |
|
|
ronmc
Starting Member
12 Posts |
Posted - 2006-03-30 : 15:28:10
|
| Ummm, almost there. The problem is that we don't want to display the time (even 00:00:00), at the presentation layer. I wish our program handled date times better, but it does not unfortunately.Thanks tough. |
 |
|
|
jhermiz
3564 Posts |
Posted - 2006-03-30 : 15:31:01
|
Presentation issue should be done in the presentation layer or try : SELECT CONVERT(varchar(10), getdate(), 101) Keeping the web experience alive -- [url]http://www.web-impulse.com[/url]RS Blog -- [url]http://weblogs.sqlteam.com/jhermiz[/url] |
 |
|
|
ronmc
Starting Member
12 Posts |
Posted - 2006-03-30 : 16:02:09
|
| Thank you. I just figured out how to make it work in my presentation layer. |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2006-03-31 : 00:42:41
|
>>I just figured out how to make it work in my presentation layer.Thats good Formation should be done thereMadhivananFailing to plan is Planning to fail |
 |
|
|
|
|
|
|
|