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 |
|
vicpal25
Starting Member
21 Posts |
Posted - 2007-04-24 : 13:15:43
|
How can I format the following query to output "mm/dd/yyyy"SELECT pEff_Dt FROM IM_Costing,IM_Demographics WHERE IM_Costing.pIM_Loc='BLA' AND IM_Costing.pItem_ID=IM_Demographics.pItem_ID AND IM_Demographics.Item_No=@v_assynoI tried:SELECT convert(datetime, pEff_Dt, 101) FROM IM_Costing,IM_Demographics WHERE IM_Costing.pIM_Loc='BLA' AND IM_Costing.pItem_ID=IM_Demographics.pItem_ID AND IM_Demographics.Item_No=@v_assynoBut that didnt work. Any suggestions? |
|
|
dinakar
Master Smack Fu Yak Hacker
2507 Posts |
Posted - 2007-04-24 : 13:18:26
|
you should do SELECT convert(varchar, pEff_Dt, 101) FROM IM_Costing,IM_Demographics WHERE IM_Costing.pIM_Loc='BLA' AND IM_Costing.pItem_ID=IM_Demographics.pItem_ID AND IM_Demographics.Item_No=@v_assyno ************************Life is short. Enjoy it.************************http://weblogs.sqlteam.com/dinakar/ |
 |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
Posted - 2007-04-24 : 13:18:38
|
| It is recommended that you don't do this in your query. It is better to format your data in your application.When you format your datetimes in T-SQL, you no longer are returning datetime data but rather character data. Tara Kizerhttp://weblogs.sqlteam.com/tarad/ |
 |
|
|
dinakar
Master Smack Fu Yak Hacker
2507 Posts |
Posted - 2007-04-24 : 13:19:28
|
quote: Originally posted by tkizer It is recommended that you don't do this in your query. It is better to format your data in your application.When you format your datetimes in T-SQL, you no longer are returning datetime data but rather character data. Tara Kizerhttp://weblogs.sqlteam.com/tarad/
Ofcouse I totally agree with Tara on that. If you can move the pretty-formatting to the front end, do it.************************Life is short. Enjoy it.************************http://weblogs.sqlteam.com/dinakar/ |
 |
|
|
vicpal25
Starting Member
21 Posts |
Posted - 2007-04-24 : 13:28:42
|
| Yeah, thats was I was first trying to implement but I am having difficulties with ADO.NET and binding to a Dataset with this value. |
 |
|
|
jsmith8858
Dr. Cross Join
7423 Posts |
Posted - 2007-04-24 : 14:20:00
|
| vicpal -- if you are using .NET, all the more reason to do the formatted there -- it is very, very easy if you return native datetimes values from your database.If you are having difficulties, please explain and we can help you out. Certainly converting everything to a VARCHAR instead of returning DateTimes shouldn't make anything easier for you or solve other issues you might be having.- Jeffhttp://weblogs.sqlteam.com/JeffS |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2007-04-30 : 10:34:42
|
quote: Originally posted by vicpal25 Yeah, thats was I was first trying to implement but I am having difficulties with ADO.NET and binding to a Dataset with this value.
Was I right in saying "Users dont know how to format dates in front end instead they simply ask here on how to do it using sql"? MadhivananFailing to plan is Planning to fail |
 |
|
|
|
|
|
|
|