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
 
@Andrew - thank-you so much that formula works perfectly and converts everything beautifully into weeks.

@Gopher - thank-you so much for such a comprehensive answer - it looks like that would be really useful - but for some reason Excel tells me I have an error when I try and paste the long TRIM formula in cell C2. I've broken it down to its constituent parts and started entering the formula bit by bit from the centre outwards if this makes sense. It works up until the point you add the second UPPER, and if you ignore it then it gives you an error when you add in the TRIM. I can see from your s/s that you got it working. But the other formulas that look at C2 show me #NAME? ....any ideas what I am doing wrong? I have all the column names correct....?
 
Upvote 0

Excel Facts

How to find 2nd largest value in a column?
MAX finds the largest value. =LARGE(A:A,2) will find the second largest. =SMALL(A:A,3) will find the third smallest
This formula should also give you total weeks

=SUM((0&MID(0&B2,FIND({"year","week"},B2&"xxxyearweek")-2,2))*{52,1})
 
Upvote 0
@Andrew - thank-you so much that formula works perfectly and converts everything beautifully into weeks.

@Gopher - thank-you so much for such a comprehensive answer - it looks like that would be really useful - but for some reason Excel tells me I have an error when I try and paste the long TRIM formula in cell C2. I've broken it down to its constituent parts and started entering the formula bit by bit from the centre outwards if this makes sense. It works up until the point you add the second UPPER, and if you ignore it then it gives you an error when you add in the TRIM. I can see from your s/s that you got it working. But the other formulas that look at C2 show me #NAME? ....any ideas what I am doing wrong? I have all the column names correct....?

Which version of Excel are you using?
 
Upvote 0
No probs.

BTW, I noticed an error in one of the SUBSTITUTE formulas. Use this instead: -

Excel Workbook
ABCDEFGHIJKLMNOPQRSTUVWXYZAAABACADAEAFAGAH
1UserMember forLast accessMember for (cleaned)YEARSMONTHSWEEKSDAYSHOURSMINSSECSYEARSMONTHSWEEKSDAYSHOURSMINSLast access (cleaned)YEARSMONTHSWEEKSDAYSHOURSMINSSECSYEARSMONTHSWEEKSDAYSHOURSMINSJOIN DATELAST ACTIVETOTAL DAYS
2user 12 years 20 weeks54 sec ago2 YEARS S 20 WEEKS2 20    730014000054 SECS AGO      5400000031/07/2009 16:0018/12/2011 16:00870
DateExtraction2
 
Upvote 0

Forum statistics

Threads
1,215,501
Messages
6,125,169
Members
449,212
Latest member
kenmaldonado

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