Solved

Finding out number of weeks by date range

Posted on 2006-07-23
6
984 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
[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
  • Learn & ask questions
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
Save the day with this special offer from ATEN!

Save 30% on the CV211 using promo code EXPERTS30 now through April 30th. The ATEN CV211 connects a laptop directly to any server allowing you instant access to perform data maintenance and local operations, for quick troubleshooting, updating, service and repair.

 

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 25

Expert Comment

by:dgrafx
ID: 17225702
0

Featured Post

Use Case: Protecting a Hybrid Cloud Infrastructure

Microsoft Azure is rapidly becoming the norm in dynamic IT environments. This document describes the challenges that organizations face when protecting data in a hybrid cloud IT environment and presents a use case to demonstrate how Acronis Backup protects all data.

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…

752 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