Hi
There is a column in my excel file which contains data in date time format : dd.yyyy hh:mm:ss:sss .z format, I want to sort my file based on this column value, but have not been successful so far.
01.20.2010 02:38:09:855 PM GMT+05:30
01.20.2010 02:38:09:855 PM GMT+05:30
01.20.2010 02:38:09:872 PM GMT+05:30
01.20.2010 11:52:52:444 AM GMT+05:30
01.20.2010 11:52:56:560 AM GMT+05:30
01.20.2010 11:52:57:569 AM GMT+05:30
01.20.2010 11:52:58:292 AM GMT+05:30
01.20.2010 11:52:59:139 AM GMT+05:30
01.20.2010 11:53:02:512 AM GMT+05:30
01.20.2010 12:07:56:998 PM GMT+05:30
01.20.2010 12:07:57:822 PM GMT+05:30
01.20.2010 12:07:58:606 PM GMT+05:30
01.20.2010 12:07:59:377 PM GMT+05:30
I searched through few forum entries, where they have advised breaking this into different fields for date and time and then sorting
Is there a way by which the data can be sorted in the same column without breaking in distinct fields.
Hi,
Into which order are you wanting to sort it?
Rgds
Richard Buttrey
If this was useful then please rate it appropriately.
Click the small star iconat the bottom left of my post.
Given AM/PM you will need to convert the strings to date time values in order to sort.
If we assume your default date format is dd mm rather than mm dd then perhaps you could use:
to generate the time based values -- against which you can apply the sort.Code:B1: =--(MID(A1,4,2)&"-"&REPLACE(SUBSTITUTE(SUBSTITUTE(LEFT(A1,26),".","-"),":",".",3),4,3,"")) copied down
My Recommended Reading:
Volatility
Sumproduct & Arrays
Pivot Intro
Email from XL - VBA & Outlook VBA
Function Dictionary & Function Translations
Dynamic Named Ranges
I have a CSV file that contains data in JAVA SimpleDateFormat as listed above, This is one of the column in the file, and I need to use this date field for generating some dynamic charts (excel OFFSET)
I require my column to be sorted in ascending order.
I tried formatting the column to date/Time/Custom types.. but it didnt help
Last edited by s1joshi; 01-31-2010 at 12:19 PM.
I tried the formula given above, and this will convert my date format to
20-01-2010 12:08:02.761 PM
20-01-2010 12:07:59.377 PM
20-01-2010 12:07:58.606 PM
20-01-2010 12:07:57.822 PM
20-01-2010 12:07:56.998 PM
20-01-2010 11:53:02.512 AM
20-01-2010 11:52:59.139 AM
20-01-2010 11:52:58.292 AM
20-01-2010 11:52:57.569 AM
20-01-2010 11:52:56.560 AM
20-01-2010 11:52:52.444 AM
20-01-2010 02:38:09.872 PM
20-01-2010 02:38:09.855 PM
20-01-2010 02:38:09.855 PM
20-01-2010 02:38:09.044 PM
20-01-2010 02:38:06.791 PM
20-01-2010 02:38:06.785 PM
20-01-2010 02:38:06.278 PM
20-01-2010 02:38:06.272 PM
But when I try to sort my spreadsheet on this column, The data doesnt seem to be sorted
(AM values in between PM for the same date)
Maybe =LEFT(SUBSTITUTE(A1, ".", "-"), 19) + MID(A1, 21, 3)/86400000 + ISNUMBER(FIND(" PM ", A1))/2
Ignores the GMT offset.
Microsoft MVP - Excel
Entia non sunt multiplicanda sine necessitate
The formula provided previously converts the Time correctly (if your standard date format is day month rather than month day)
EDIT: shg's will work only if the opposite is true (ie month day standard format)
The AM/PM in your resulting values is down to the format you have applied to the data.
If I sort the values you list in your prior post (ie formulae results) they are listed in order as expected - ie for me they are numerics - we're assuming the same is true for you (ie no #VALUE! output)
Like shg's formula the earlier formula assumes the GMT offset is consistent, ie is ignored.
If you need further assistance post a file.
Last edited by DonkeyOte; 01-31-2010 at 02:40 PM.
My Recommended Reading:
Volatility
Sumproduct & Arrays
Pivot Intro
Email from XL - VBA & Outlook VBA
Function Dictionary & Function Translations
Dynamic Named Ranges
Hi
Can you please have a look -
I would suggest perhaps trying the actual formula provided earlier...
Note specifically those characters that appear post equals sign in my formula but that are missing in yours.
My Recommended Reading:
Volatility
Sumproduct & Arrays
Pivot Intro
Email from XL - VBA & Outlook VBA
Function Dictionary & Function Translations
Dynamic Named Ranges
Really appreciate your quick response, time and effort in helping me on the issue , actually I was getting an error with the two sign's, Can you elaborate on the formula or point me to some link, which I can refer to understand the process of converting string to excel date format
If you dont mind can you share your worksheet
Last edited by s1joshi; 01-31-2010 at 04:10 PM.
If you get a #VALUE! error then the implication is that your default date format is in fact month day year rather than day month year, in which case try either shg's version or:
If the above also returns #VALUE! then try:Code:B2: =--SUBSTITUTE(SUBSTITUTE(LEFT(A2,26),".","-"),":",".",3)
If neither of the above work you will need to detail your default date format.Code:B2: =--SUBSTITUTE(LEFT(A2,26),":",".",3)
ie - if you enter a datetime value into a cell in what format are you entering it ?
My Recommended Reading:
Volatility
Sumproduct & Arrays
Pivot Intro
Email from XL - VBA & Outlook VBA
Function Dictionary & Function Translations
Dynamic Named Ranges
Thanks so much for your assistance in helping with the issue.
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks