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 |
|
fabianus76
Posting Yak Master
191 Posts |
Posted - 2006-02-24 : 15:59:27
|
| I would like to output a certain date format. In Access I do it like that : SELECT format(mydate,'yyyymmdd') as mydate FROM mytableCould someone tell me how to do this in sql-server 2005 ?Thank you very much!Regards,Fabianmy favorit hoster is ASPnix : www.aspnix.com ! |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
Posted - 2006-02-24 : 16:00:51
|
| Check out the different styles of the CONVERT function in SQL Server Books Online. Style 112 will give you that format.Tara Kizeraka tduggan |
 |
|
|
fabianus76
Posting Yak Master
191 Posts |
Posted - 2006-02-24 : 16:18:41
|
| Hey Tara!Thanks for this quick help!!!Regards,FabianPS I like this format function of Access - no need to keep in mind the 112 or whatever :-(my favorit hoster is ASPnix : www.aspnix.com ! |
 |
|
|
Srinika
Master Smack Fu Yak Hacker
1378 Posts |
Posted - 2006-02-24 : 16:22:19
|
| U don't have to keep in mind, me neitherThat's y there is BOL |
 |
|
|
jsmith8858
Dr. Cross Join
7423 Posts |
Posted - 2006-02-24 : 16:48:08
|
| >>PS I like this format function of Access - no need to keep in mind the 112 or whatever :-(Formatting is not *supposed* to be easy and convienant in SQL Server. It's not designed to do it!Formatting should always be done at the client; SQL should return datetime data back for dates, not varchar()'s in a particular format.If you return formatted VARCHAR's, when the client wants to format, peform calculations, sort, or do anything with that date, it will immediately need to cast it BACK to a datetime! In addition to now needing to deal with parsing the varchar() in the date format you chose to put it in. Just return DATA from your database. |
 |
|
|
Kristen
Test
22859 Posts |
Posted - 2006-02-25 : 02:14:42
|
I agree, of course, but why does Query Analyser have to display dates with a width of 54 characters?SELECT GetDate() (in "Results in Text" mode) Kristen |
 |
|
|
|
|
|
|
|