Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Finding out number of weeks by date range

Posted on 2006-07-23
6
Medium Priority
?
1,002 Views
Last Modified: 2013-12-24
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
Comment
Question by:moyedokun
6 Comments
 
LVL 11

Expert Comment

by:adonis1976
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

by:usachrisk1983
usachrisk1983 earned 1600 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

by:adonis1976
ID: 17168108
yep sir.. agree with you.. i was asleep when I wrote that code..
0
Vote for the Most Valuable Expert

It’s time to recognize experts that go above and beyond with helpful solutions and engagement on site. Choose from the top experts in the Hall of Fame or on the right rail of your favorite topic page. Look for the blue “Nominate” button on their profile to vote.

 

Author Comment

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

Accepted Solution

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

datediff("ww",   etc...
0
 
LVL 25

Expert Comment

by:dgrafx
ID: 17225702
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Article by: kevp75
Hey folks, 'bout time for me to come around with a little tip. Thanks to IIS 7.5 Extensions and Microsoft (well... really Windows 8, and IIS 8 I guess...), we can now prime our Application Pools, when IIS starts. Now, though it would be nice t…
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.
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…
Please read the paragraph below before following the instructions in the video — there are important caveats in the paragraph that I did not mention in the video. If your PaperPort 12 or PaperPort 14 is failing to start, or crashing, or hanging, …

963 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question