Solved

Finding out number of weeks by date range

Posted on 2006-07-23
6
968 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 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

by:adonis1976
ID: 17168108
yep sir.. agree with you.. i was asleep when I wrote that code..
0
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 

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 100 total points
ID: 17190916
Just need to put the ww between quotes

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

Expert Comment

by:dgrafx
ID: 17225702
0

Featured Post

Get up to 2TB FREE CLOUD per backup license!

An exclusive Black Friday offer just for Expert Exchange audience! Buy any of our top-rated backup solutions & get up to 2TB free cloud per system! Perform local & cloud backup in the same step, and restore instantly—anytime, anywhere. Grab this deal now before it disappears!

Join & Write a Comment

One of the typical problems I have experienced is when you have to move a web server from one hosting site to another. You normally prepare all on the new host, transfer the site, change DNS and cross your fingers hoping all will be ok on new server…
Meet the world's only “Transparent Cloud™” from Superb Internet Corporation. Now, you can experience firsthand a cloud platform that consistently outperforms Amazon Web Services (AWS), IBM’s Softlayer, and Microsoft’s Azure when it comes to CPU and …
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…

708 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now