Solved

# Finding out number of weeks by date range

Posted on 2006-07-23
984 Views
I have a record with a date range.  Is there a way to determine the number of weeks that is included in the date range?
0
Question by:moyedokun
[X]
###### Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

• Help others & share knowledge
• Earn cash & points

LVL 11

Expert Comment

ID: 17165057
Say for example you have a record like 07/23/2006-07/20/2006

You can do something like this:

<cfset sDate = "07/23/2006-07/20/2006"

<cfset iWeeks = datediff(ww,listLast(sDate),listFirst(sDate))>

iWeeks should give you the difference in weeks..
0

LVL 13

Assisted Solution

usachrisk1983 earned 400 total points
ID: 17167364
Slight modification to one of your lines:

<cfset iWeeks = datediff(ww,listLast(sDate),listFirst(sDate))>

should be

<cfset iWeeks = datediff(ww,listLast(sDate,'-'),listFirst(sDate,'-'))>

If the data is stored as "07/23/2006-07/20/2006"

This is because both ListFirst and ListLast will be looking for a comma as a delim, and when it doesn't find one, will assume it's just a one item list.
0

LVL 11

Expert Comment

ID: 17168108
yep sir.. agree with you.. i was asleep when I wrote that code..
0

Author Comment

ID: 17189930
I get an error.  It is telling me that ww is undefined.
0

LVL 15

Accepted Solution

tim_cs earned 100 total points
ID: 17190916
Just need to put the ww between quotes

datediff("ww",   etc...
0

LVL 25

Expert Comment

ID: 17225702
0

## Featured Post

Question has a verified solution.

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

If you don't have the right permissions set for your WordPress location in IIS, you won't be able to perform automatic updates. Here's how to fix the problem.
When it comes to showing a 404 error page to your visitors, you do not want that generic page to show, and you especially do not want your hosting provider’s ad error page to show either. In this article, I will show you how to enable the custom 40…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…
###### Suggested Courses
Course of the Month2 days, 7 hours left to enroll