Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Customer Excel Data Format

Posted on 2014-02-27
4
Medium Priority
?
282 Views
Last Modified: 2014-02-27
Hello,
I have data that contains time stamps in this format:

Thu 9 Jan 00:01:24
Fri 10 Jan 23:33:29

I'm trying to put a customer date format on it so I can group the data.  I tried:
ddd d mmm hh:mm:ss
but it doesn't seem to work.  Can someone help me put the right format in please?
Thanks,
Tod
0
Comment
Question by:tkeiffer
  • 2
  • 2
4 Comments
 
LVL 81

Accepted Solution

by:
byundt earned 2000 total points
ID: 39893711
Try using the Data...Text to Columns menu item to convert your time stamps into date/time serial numbers that you can format as desired.

1.  Select the cells
2.  Open the Data...Text to Columns menu item
3.  Choose Fixed in the first step of the wizard
4.  In the third step of the wizard, choose to not import the first field, and to import the second field as a Date in DMY format
5.  Format the results to suit

Macro equivalent to steps 1 through 4:
Sub ConvertDates()
    Selection.TextToColumns Destination:=Selection.Cells(1, 1), DataType:=xlFixedWidth, _
        FieldInfo:=Array(Array(0, 9), Array(3, 4)), TrailingMinusNumbers:=True
End Sub

Open in new window

0
 

Author Comment

by:tkeiffer
ID: 39893770
Hello,
The problem with the text to columns using a fixed type, is that the 1-9 dates do not have a zero before them so the fixed length is different.  While I was waiting for a response to this question I did a find/replace for space 1 space with a space 01 space, and did that through 9.  I then did a text to columns and this worked.  However, I need something more practical because I'm creating a template for someone to use and it needs to be somewhat simple.  The macro works great and converts the data to a format where excel recognizes it as a time stamp.  Thank you very much.
0
 
LVL 81

Expert Comment

by:byundt
ID: 39893789
The problem with the text to columns using a fixed type, is that the 1-9 dates do not have a zero before them so the fixed length is different.
The suggested macro was recorded when I used the TextToColumns manual method. The wizard put the fixed field break after the third character, so you got a leading space before both single and double digit dates in the other field. The converter uses the rest of the data as the second field, so you don't need to specify its length. The converter also ignores the leading space when doing the conversion.

Brad
0
 

Author Comment

by:tkeiffer
ID: 39893798
You're the man.  I never knew the rule about the leading space.  That would have saved me some time throughout the years that's for sure!  Thanks again.
0

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

How to get Spreadsheet Compare 2016 working with the 64 bit version of Office 2016
Microsoft's Excel has many features that most people will never need nor take advantage of.  Conditional formatting is one feature that you may find a necessity once you start using it.
The viewer will learn how to use a discrete random variable to simulate the return on an investment over a period of years, create a Monte Carlo simulation using the discrete random variable, and create a graph to represent the possible returns over…
This Micro Tutorial will demonstrate on a Mac how to change the sort order for chart legend values and decrpyt the intimidating chart menu.

916 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question