Formula to convert human-readable text strings into a consistent number of weeks from today's date?

loto

New Member
Joined
Dec 17, 2011
Messages
11
Hi there, is it possible to do the following with a formula in Excel...

I have a list of users with the dates they first logged into a system and the date they last logged in. I'm trying to group them together into segments so I can analyse them using a Pivot table and chart to see how often different groups are using the system, e.g. New customers in December, November, October, etc.

The trouble I am having is trying to convert the different human-readable text strings into a consistent number of weeks from today's date, e.g.

USER FIRST LOGGED IN LAST LOGGED IN
user 1 2 years 20 weeks 54 sec ago
user 2 44 min 7 sec 1 min 37 sec ago
user 3 49 weeks 2 days 17 min 3 sec ago
user 4 5 weeks 2 days 33 min 32 sec ago
user 5 38 min 9 sec 38 min 9 sec ago
user 6 5 weeks 3 days 1 hour 7 min ago
user 7 2 hours 17 min 2 hours 11 min ago
user 8 45 seconds ago 45 seconds ago

Is there a formula I can use to convert these human readble text strings into a number of weeks elapsed since today's date?

Thanks

loto
 

Excel Facts

Remove leading & trailing spaces
Save as CSV to remove all leading and trailing spaces. It is faster than using TRIM().
Welcome to MrExcel.

It's difficult to tell what's in what column there. Can you try surrounding your data with borders and reposting please?
 
Upvote 0
Hi there...I've uploaded it to Google docs in case you can't see the data properly...
https://docs.google.com/spreadsheet/ccc?key=0Avu18NHHmONKdE8taTlZY01pMFJKTDVYZktlUFpMcmc

<table width="467" border="0" cellpadding="0" cellspacing="0"><colgroup><col style="width:48pt" span="2" width="64"> <col style="mso-width-source:userset;mso-width-alt:4022; width:83pt" span="2" width="110"> <col style="mso-width-source:userset;mso-width-alt:4352;width:89pt" width="119"> </colgroup><tbody><tr style="height:12.75pt" height="17"> <td class="xl24" style="height:12.75pt;width:48pt" height="17" width="64">User</td> <td class="xl24" style="border-left:none;width:48pt" width="64"> </td> <td class="xl24" style="border-left:none;width:83pt" width="110">Member for</td> <td class="xl24" style="border-left:none;width:83pt" width="110"> </td> <td class="xl24" style="border-left:none;width:89pt" width="119">Last access

</td> </tr> <tr style="height:12.75pt" height="17"> <td class="xl25" style="height:12.75pt;border-top:none" height="17">user 1</td> <td class="xl25" style="border-top:none;border-left:none"> </td> <td class="xl26" style="border-top:none;border-left:none">2 years 20 weeks</td> <td class="xl26" style="border-top:none;border-left:none"> </td> <td class="xl25" style="border-top:none;border-left:none">54 sec ago</td> </tr> <tr style="height:12.75pt" height="17"> <td class="xl25" style="height:12.75pt;border-top:none" height="17">user 2</td> <td class="xl25" style="border-top:none;border-left:none"> </td> <td class="xl26" style="border-top:none;border-left:none">44 min 7 sec</td> <td class="xl26" style="border-top:none;border-left:none"> </td> <td class="xl25" style="border-top:none;border-left:none">1 min 37 sec ago</td> </tr> <tr style="height:12.75pt" height="17"> <td class="xl25" style="height:12.75pt;border-top:none" height="17">user 3</td> <td class="xl25" style="border-top:none;border-left:none"> </td> <td class="xl26" style="border-top:none;border-left:none">49 weeks 2 days</td> <td class="xl26" style="border-top:none;border-left:none"> </td> <td class="xl25" style="border-top:none;border-left:none">17 min 3 sec ago</td> </tr> <tr style="height:12.75pt" height="17"> <td class="xl25" style="height:12.75pt;border-top:none" height="17">user 4</td> <td class="xl25" style="border-top:none;border-left:none"> </td> <td class="xl26" style="border-top:none;border-left:none">5 weeks 2 days</td> <td class="xl26" style="border-top:none;border-left:none"> </td> <td class="xl25" style="border-top:none;border-left:none">33 min 32 sec ago</td> </tr> <tr style="height:12.75pt" height="17"> <td class="xl25" style="height:12.75pt;border-top:none" height="17">user 5</td> <td class="xl25" style="border-top:none;border-left:none"> </td> <td class="xl26" style="border-top:none;border-left:none">38 min 9 sec</td> <td class="xl26" style="border-top:none;border-left:none"> </td> <td class="xl25" style="border-top:none;border-left:none">38 min 9 sec ago</td> </tr> <tr style="height:12.75pt" height="17"> <td class="xl25" style="height:12.75pt;border-top:none" height="17">user 6</td> <td class="xl25" style="border-top:none;border-left:none"> </td> <td class="xl26" style="border-top:none;border-left:none">5 weeks 3 days</td> <td class="xl26" style="border-top:none;border-left:none"> </td> <td class="xl25" style="border-top:none;border-left:none">1 hour 7 min ago</td> </tr> <tr style="height:12.75pt" height="17"> <td class="xl25" style="height:12.75pt;border-top:none" height="17">user 7</td> <td class="xl25" style="border-top:none;border-left:none"> </td> <td class="xl26" style="border-top:none;border-left:none">2 hours 17 min</td> <td class="xl26" style="border-top:none;border-left:none"> </td> <td class="xl25" style="border-top:none;border-left:none">2 hours 11 min ago</td> </tr> <tr style="height:12.75pt" height="17"> <td class="xl25" style="height:12.75pt;border-top:none" height="17">user 8</td> <td class="xl25" style="border-top:none;border-left:none"> </td> <td class="xl26" style="border-top:none;border-left:none">15 weeks 1 day</td> <td class="xl26" style="border-top:none;border-left:none"> </td> <td class="xl25" style="border-top:none;border-left:none">3 hours 13 min ago</td> </tr> </tbody></table>

Thanks!
 
Upvote 0
To convert the entry in C2 to a serial time:

=(IF(ISERROR(FIND("hour",C2)),"0:","")&IF(ISERROR(FIND("min",C2)),"0:","")&SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(C2,"ago",""),"hours","hour")," hour ",":")," min ",":")," sec ","")&IF(ISERROR(FIND("sec",C2)),"0",""))+0

formatted as hh:mm:ss.
 
Upvote 0
Thanks Andrew...you're clearly a genius ;).... that's resolved column c nicely. If I want to also convert the dates in column b to 'weeks from today's date' - can I use a similar approach but format the data differently? Any ideas? e.g. I would like to convert 2 years 20 weeks ago to x number of weeks from 17/12/11, e.g. giving me approximately 124 weeks.

Thanks again.
 
Upvote 0
I haven't had a chance to double-check this, so take it as a UAT version and have a play around with it. It calculates the number of months from the date data given in column B, then uses EDATE() to subtract the number of months from TODAY().

Excel Workbook
ABCDEFGHIJKLMNOPQRS
1UserMember forLast accessYEARSMONTHSWEEKSDAYSHOURSMINSSECSYEARSMONTHSWEEKSDAYSHOURSMINSTOTALINITIAL DATE
2user 12 years 20 weeks2 YEARS 20 WEEKS54 sec ago2 20    2404.600028.617/08/2009
Sheet7



http://www.excel-jeanie-html.de/index.php?f=1
 
Upvote 0
Try:

=IF(ISNUMBER(FIND("min",B2)),0,IF(ISNUMBER(FIND("year",B2)),LEFT(B2,FIND(" year",B2)-1)*52,0)+IF(ISNUMBER(FIND("week",B2)),IF(ISNUMBER(FIND("year",B2)),MID(B2,FIND(" week",B2)-2,2),LEFT(B2,FIND(" week",B2)-1)),0))
 
Upvote 0
The only definite inaccuracy in that is that it assumes 365 as the number of days in a year (might is slightly inaccurate, but probably not consequential for this matter).

I will have to double-check the MID formulas to make sure they are definitely extracting the correct values from the initial text.
 
Upvote 0
This should give you join date, last use date and number of days from join date to present.

Excel Workbook
ABCDEFGHIJKLMNOPQRSTUVWXYZAAABACADAEAFAGAH
1UserMember forLast accessMember for (cleaned)YEARSMONTHSWEEKSDAYSHOURSMINSSECSYEARSMONTHSWEEKSDAYSHOURSMINSLast access (cleaned)YEARSMONTHSWEEKSDAYSHOURSMINSSECSYEARSMONTHSWEEKSDAYSHOURSMINSJOIN DATELAST ACTIVETOTAL DAYS
2user 12 years 20 weeks54 sec ago2 YEARS 20 WEEKS2 20    730014000054 SECS AGO      5400000030/07/2009 18:4317/12/2011 18:43870
DateExtraction2



http://www.excel-jeanie-html.de/index.php?f=1
 
Upvote 0

Forum statistics

Threads
1,215,006
Messages
6,122,666
Members
449,091
Latest member
peppernaut

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top