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.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Formatting

Author  Topic 

jcb267
Constraint Violating Yak Guru

291 Posts

Posted - 2011-06-28 : 12:59:03
Hi -

I have a field called GroupSize that has values such as 1-5, 6-10, etc. When I call this field in a query, sql displays is properly but when I copy it to excel it is formatted as a date. For example 1-5 comes over as 5-Jan. Do i need to convert it in excel?? Can anyone help??

Thanks very much,

JB

robvolk
Most Valuable Yak

15732 Posts

Posted - 2011-06-28 : 13:03:35
You'll need to format the cells in Excel at Text, then paste. There's nothing to do on the SQL Server side.
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2011-06-28 : 13:03:36
You just need to format the cell in Excel. The data is still there in the raw format, just displayed wrong.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2011-06-28 : 13:04:04
1 second!

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page

jcb267
Constraint Violating Yak Guru

291 Posts

Posted - 2011-06-28 : 13:11:49
I tried changing the format in excel, it is still happening. I cheated, shhhh....I put a character in from of my code - 1-5 is now s1-5.....I still want to know the correct way to do it though!
quote:
Originally posted by tkizer

1 second!

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog

Go to Top of Page

robvolk
Most Valuable Yak

15732 Posts

Posted - 2011-06-28 : 13:27:45
There's no "correct" way, it's Excel's fault because it tries to interpret the type of data. The only way to prevent that is to format the cells as Text (instead of General, Number, etc.) You have to do that before you paste data from another source.
Go to Top of Page
   

- Advertisement -