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 |
|
mridang_agarwal
Starting Member
22 Posts |
Posted - 2006-11-08 : 04:55:59
|
| Hi guys,I'm using SQL Server 2000 and I'm facing a small problem. I have some values stored in a datetime field. When I use a simple query to retrieve the date from the datetime column, SQL Server returns a date in the loon datetime format. I wish to view the date in the order mm-dd-yyyy. How do I do this? It might seem like a simple question for of but I couldn't figure it out myself ever after Googling for an hour!Thanks in advance guys. |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2006-11-08 : 05:06:01
|
| Format the datetime at client side and do not worry about datetime format in the database!However, if you insist in doing this,SELECT CONVERT(varchar, mydatetimecolumn, 110)might help. Took me about 9 seconds to search Books Online...Peter LarssonHelsingborg, Sweden |
 |
|
|
mridang_agarwal
Starting Member
22 Posts |
Posted - 2006-11-08 : 05:50:55
|
| Why do you say that we should convert the date at the client side? Would this result in a slight performance boost considering the fact that there be thousands of records. |
 |
|
|
harsh_athalye
Master Smack Fu Yak Hacker
5581 Posts |
Posted - 2006-11-08 : 06:07:47
|
| Because data formatting and presentation is the job of presentation layer (front-end) and bringing accurate data in quickest possible manner is the job of the back-end. Don't mix them up, if you prefer better design.Harsh AthalyeIndia."Nothing is Impossible" |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2006-11-09 : 11:21:22
|
quote: Originally posted by mridang_agarwal Why do you say that we should convert the date at the client side? Would this result in a slight performance boost considering the fact that there be thousands of records.
When you convert in in sql, dates become date-like-varchars so that you cant do calculations on that before converting it to datetimeMadhivananFailing to plan is Planning to fail |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2006-11-09 : 11:23:00
|
>> Format the datetime at client side and do not worry about datetime format in the database! Longer version of "Do it in front end application" MadhivananFailing to plan is Planning to fail |
 |
|
|
deanheathen
Starting Member
4 Posts |
Posted - 2006-11-11 : 11:56:53
|
| by client side he means in your code once you return your value. for example if you were using VB, you might try:format(rs.fields("FieldName"),"MM-DD-YYYY HH:MM:SS")DH |
 |
|
|
|
|
|