Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 10-29-2013, 04:05 PM
step10 step10 is offline Date field Mac OS X Date field Office 2007
Novice
Date field
 
Join Date: Oct 2013
Location: USA
Posts: 11
step10 is on a distinguished road
Default Date field

Hello,



I have a .csv file that automatically opens up in Microsoft Excel 2010 and one of the fields is a date field that displays as Mar-13 (example);, but when you click in the field, it shows "March 13, 2013". How do I get this to display as is and not be automatically converted?

I've tried setting it as custom and put the date format in and I've tried setting it to a text field, but nothing seems to work.

Is there something in Excel, that automatically converts the date field to a specific format, and if so, how do I turn this off?

Thanks.
Reply With Quote
  #2  
Old 10-30-2013, 12:14 AM
macropod's Avatar
macropod macropod is offline Date field Windows 7 32bit Date field Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,962
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

If you want 'Mar-13' to remain 'Mar-13', you would probably need to use either:
• Excel's Data>Get External Data>From Text function and set the comma delimiter then format the affected column as text; or
• a macro to convert the date back to a string after opening in Excel.
Note that you'll need to do this every time you open the csv file.

The alternative is to use a macro to read the csv file into Excel one line at a time and output each affected field in text format. This would be a much slower process, though, and would still need to be done every time you open the csv file.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #3  
Old 10-30-2013, 09:34 AM
BobBridges's Avatar
BobBridges BobBridges is offline Date field Windows 7 64bit Date field Office 2010 32bit
Expert
 
Join Date: May 2013
Location: USA
Posts: 700
BobBridges has a spectacular aura aboutBobBridges has a spectacular aura about
Default

What you have to understand, step10, is that a CSV file is a sort of extract of a single worksheet that contains just the text of each cell's value. No formulae, just the results. No formatting, which means no fonts, colors, borders or special output formats, including dates.

Therefore when you read in a CSV, Excel can see only the value, not the way you want it expressed. If you want to save a date format from one session to the next, you have to save the worksheet in one of the formats (using Save As) that isn't text only. That's most of them; the default is .xls[x], and it'll save all that stuff for you. Really CSV is intended only to help you transfer data between Excel and other applications.
Reply With Quote
  #4  
Old 10-30-2013, 08:46 PM
macropod's Avatar
macropod macropod is offline Date field Windows 7 32bit Date field Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,962
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

Quote:
Originally Posted by BobBridges View Post
Therefore when you read in a CSV, Excel can see only the value, not the way you want it expressed.
Bob,

I think you've misunderstood the issue, which is that Excel is converting the text string 'Mar-13' in the CSV file to the date 'March 13, 2013'. If Excel truly returned only the content of the CSV as you suggest, instead of 'interpreting' it, that wouldn't happen.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #5  
Old 10-31-2013, 04:36 PM
BobBridges's Avatar
BobBridges BobBridges is offline Date field Windows 7 64bit Date field Office 2010 32bit
Expert
 
Join Date: May 2013
Location: USA
Posts: 700
BobBridges has a spectacular aura aboutBobBridges has a spectacular aura about
Default

You may be right, Paul; I'm certainly not understanding something.

Here's what I think I'm hearing: In the CSV is some text that reads "...<date>...", with commas around it. When Excel reads the CSV, step10 reports that the date is displayed as "Mar-13" in the cell, but when he clicks on it it displays "March 13, 2013" in the formula bar. (Right, step10?) He reports this as a problem, believing that Excel is "changing" something. Me, I don't think that's what's happening; I think all that's happening is that Excel is choosing the default format for displaying dates. And I suspect that step10 has already tried changing the format of the date to suit him, then saved the worksheet again—still as a CSV—and is frustrated that when he opens the CSV again later, the date is no longer in the format he selected, but back to the original one.

You suggested some ways he could ensure that the format is set correctly (again) every time he opens the CSV. I went on to explain why a CSV can never actually retain the format from one session to the next.

So the issue (I think) is that Excel is behaving as it's designed, but step10 simply didn't understand what a CSV is supposed to be. But you say the issue is ... I'm not sure I follow it. Am I missing something, or did I just phrase it misleadingly, the first time?
Reply With Quote
Reply



Similar Threads
Thread Thread Starter Forum Replies Last Post
Date field inserting merge date in blank field Lesley Mail Merge 5 09-30-2013 01:49 AM
Date field Field Date: UCase()? tinfanide Word VBA 5 02-08-2013 03:01 PM
Date field Date Field to add 10 Days to Current Date Erbwon Word 6 11-12-2012 06:17 PM
Please help me with creating due date field Artemio Word 1 03-01-2012 08:10 PM
Formula to subtract one month from due date field in reminder field ghumdinger Outlook 1 10-01-2011 12:09 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 05:05 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft