My Assistant
![]() ![]() |
MS Excel, Cell format issues |
Nov 12 2006, 06:33 PM
Post
#1
|
|
|
Founder ![]() ![]() ![]() ![]() Group: Chairman Posts: 14445 Joined: 8-February 04 Member No.: 1 |
This is a date/time format I often come across when looking a spaceflight related data from places such as the PDS or the radiation / relay logs...
2004-01-02T19:15:38 or 2006-315T23:03:23.0(one using yyyy-mm-dd and one using yyyy-ddd etc ) Try as I might, I can't get Excel to 'read' these properly, even using my own custom cell format type as yyyy-ddd"T"hh:mm:ss.s Any pointers? Doug |
|
|
|
Nov 12 2006, 06:54 PM
Post
#2
|
|
![]() Dublin Correspondent ![]() ![]() ![]() ![]() Group: Admin Posts: 1799 Joined: 28-March 05 From: Celbridge, Ireland Member No.: 220 |
When I come across issues like this I usually "clean" up the data using Perl but that's not an option for most folks.
Within Excel itself you could do the following for the first format: Col A - Imported String value (2004-01-02T19:15:38) Col B - =Left(A1,10) (== 2004-01-02) Col C - =DateValue(B1) (==37988) Col D - =Right(A1,9) (==19:15:38) Col E - =TimeValue(D1) (==0.802523148) Col F - =C1+E1. you might have to set the default date format appropriately first or build the Date string into YYY-MM-DD first to ensure the Month\Day order format is correct. for the second format (2006-315T23:03:23.0) Col A - Imported String value (2004-01-02T19:15:38) Col B - =Left(A1,4) (== 2004) Col C - =mid(A1,6,3) (==315) Col D - =Date(B1,1,1)-1 (31/12/2005) Col E -=D1+C1 Then proccess the time as before and add it to the date value. You would probably carry out all of the above in a single cell but I've broken it out for clarity. Of course I'm assuming that the data\time formats use a fixed string length for each data item (e.g. Day 4 of the year in the second format is represented by 004). That's why I'd use Perl by preference. 2004-01-02T19:15:38 2004-01-02T19:15:38 |
|
|
|
Nov 12 2006, 07:43 PM
Post
#3
|
|
|
Junior Member ![]() ![]() Group: Members Posts: 63 Joined: 20-April 05 Member No.: 312 |
Doug
Copy your Date / Time string into Column A e.g 2004-01-02T19:15:38 into cell A1 Cells in Column B should have formula =DATE(MID(A1,1,4),MID(A1,6,2),MID(A1,9,2)) This rewolves the Date Part Cells in Column C should have the formula =TIME(MID(A1,12,2),MID(A1,15,2),MID(A1,18,2)) I think that should do that you want assuming the Date / Time strings are all fixed length Regards Brianc |
|
|
|
Nov 12 2006, 08:36 PM
Post
#4
|
|
|
Founder ![]() ![]() ![]() ![]() Group: Chairman Posts: 14445 Joined: 8-February 04 Member No.: 1 |
Wow - I'll try these later
Doug |
|
|
|
Nov 12 2006, 10:05 PM
Post
#5
|
|
![]() Junior Member ![]() ![]() Group: Members Posts: 60 Joined: 1-August 06 From: Vienna, Austria Member No.: 1002 |
Doug
For the second format e.g 2006-315T23:03:23.0 In Column B use formula =DATE(LEFT(A1,4),1,1)+MID(A1,6,3)-1 and in Column C use formula =TIME(MID(A1,10,2),MID(A1,13,2),MID(A1,16,2)) As Brianc states, these assume the Date / Time strings are all fixed length, if not you'll have to use the LEN function. Aye |
|
|
|
Nov 12 2006, 10:31 PM
Post
#6
|
|
![]() Dublin Correspondent ![]() ![]() ![]() ![]() Group: Admin Posts: 1799 Joined: 28-March 05 From: Celbridge, Ireland Member No.: 220 |
The problem with dealing with potentially variable length date items got me thinking that there is a simpler way:
Col A - Imported String value (2004-01-02T19:15:38) Col B - = VALUE(SUBSTITUTE(A1,"T"," ")) (convert to the correct date and time) Provided your default date format's year/month/day dequence order matches the input data this will work. |
|
|
|
Nov 12 2006, 10:38 PM
Post
#7
|
|
|
Merciless Robot ![]() ![]() ![]() ![]() Group: Admin Posts: 8789 Joined: 8-December 05 From: Los Angeles Member No.: 602 |
Sure glad to see that there are some Excel whizzes here. I'm taking a class (systems optimization) that is almost literally killing me with novel Excel applications...might ask you guys for some pointers as well!
-------------------- A few will take this knowledge and use this power of a dream realized as a force for change, an impetus for further discovery to make less ancient dreams real.
|
|
|
|
![]() ![]() |
|
Lo-Fi Version | Time is now: 26th October 2024 - 01:06 AM |
|
RULES AND GUIDELINES Please read the Forum Rules and Guidelines before posting. IMAGE COPYRIGHT |
OPINIONS AND MODERATION Opinions expressed on UnmannedSpaceflight.com are those of the individual posters and do not necessarily reflect the opinions of UnmannedSpaceflight.com or The Planetary Society. The all-volunteer UnmannedSpaceflight.com moderation team is wholly independent of The Planetary Society. The Planetary Society has no influence over decisions made by the UnmannedSpaceflight.com moderators. |
SUPPORT THE FORUM Unmannedspaceflight.com is funded by the Planetary Society. Please consider supporting our work and many other projects by donating to the Society or becoming a member. |
|