Ask a Question related to Coldfusion - Advanced Techniques, Design and Development.
-
Unamailer #1
Date Range from Week Number
Has anyone ever tried to create a date range from a week number? Here is my
scenario: I have a database with a primary key of weekNum. There are 52
entries in this DB ranging from 1-52. I want to list out these entries as date
ranges. For example: Week 9 (Feb. 20 - Feb. 26) Week 10 (Feb. 27 - Mar. 5)
etc.... Any help or ideas would be greatly appreciated.
Unamailer Guest
-
#39912 [NEW]: date('W') returns wrong week number for some dates
From: pkus at epf dot pl Operating system: windows xp PHP version: 5.2.0 PHP Bug Type: *General Issues Bug description: ... -
Code for telling the week number on a specific date
I've been annoyed that the Date class had no ability to tell which week a certain date fell within. So I created a function that will take any date... -
Covert Date to week number
Is their a way in PERL to covert a date to a week number Cheers Neill -
Convert Date to week number
Tim wrote: ISO8601 defines a standard, but not everyone follows it. See: ... -
Parsing a date from the week number of a given year from request post
I'm trying to get the date from a request-query post that contains a year (request("season") and a week number from that year... -
philh #2
Re: Date Range from Week Number
Try the attached code for some ideas.
<cfif IsDefined("form.bleah")>
<cfset firstday = "01/01/"&datepart("yyyy",now())>
<Cfset refday = dateadd("ww", form.checkdate -1 ,firstday)>
<cfset thisday = refday>
<CFSET first_day_of_last_week = DateAdd("d", (DayOfWeek(thisday)-1)*-1,
thisday)>
<CFSET last_day_of_last_week = DateAdd("d", 6, first_day_of_last_week)>
</cfif>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>Untitled</title>
</head>
<body>
<cfif IsDefined("form.bleah")><cfoutput>For week number #form.checkdate#,
we use #firstday# as a reference (You can manipulate the reference date in
line 2 of this script). #form.checkdate# weeks from this date is
#dateformat(thisday,"mm/dd/yyyy")#, which
is in the week from #dateformat(first_day_of_last_week,"mm/dd/yyyy")#
- #dateformat(last_day_of_last_week,"mm/dd/yyyy")# , so
#dateformat(first_day_of_last_week,"mm/dd/yyyy")#
is the first day of week #form.checkdate#.
</cfoutput></cfif>
<form action="first_day_of_any_week.cfm" method="post">
Enter week number:<input type="text" name="checkdate"><br>
<input type="submit" name="bleah" value="Get date info"></form>
</body>
</html>
philh Guest
-
Unamailer #3
Re: Date Range from Week Number
Phil:
Thanks for the help! This worked like a champ!!!
I was able to use the code that you provided and modify it for an exact solution.
Thanks again!!!
Unamailer Guest



Reply With Quote

