Important alert: (current site time 7/16/2013 6:51:25 AM EDT)
 

VB icon

Generating 1st and 3rd Saturday a year

Email
Submitted on: 6/27/2002 4:36:50 AM
By: encrytedboy 
Level: Intermediate
User Rating: Unrated
Compatibility: Cold Fusion 4.5
Views: 8480
(About the author)
 
     generating a list of 1st and 3rd saturday
 
Can't Copy and Paste this?
Click here for a copy-and-paste friendly version of this code!
//**************************************
// for :Generating 1st and 3rd Saturday a year
//**************************************
(SOURCE SHARE)
code:
Can't Copy and Paste this?
Click here for a copy-and-paste friendly version of this code!
 
Terms of Agreement:   
By using this code, you agree to the following terms...   
  1. You may use this code in your own programs (and may compile it into a program and distribute it in compiled format for languages that allow it) freely and with no charge.
  2. You MAY NOT redistribute this code (for example to a web site) without written permission from the original author. Failure to do so is a violation of copyright laws.   
  3. You may link to this code from another website, but ONLY if it is not wrapped in a frame. 
  4. You will abide by any additional copyright restrictions which the author may have placed in the code or code's description.
				
//**************************************
// Name: Generating 1st and 3rd Saturday a year
// Description:generating a list of 1st and 3rd saturday
// By: encrytedboy
//
// Inputs:year and maybe none
//
// Returns:list of date (1st and 3rd only)
//
//This code is copyrighted and has// limited warranties.Please see http://www.Planet-Source-Code.com/vb/scripts/ShowCode.asp?txtCodeId=52&lngWId=9//for details.//**************************************

<!---
Creator : Ahmad Bakri Bin Mohd Samuri
E-Mail : cureorcurse@msn.com | ahmadbakri@compubox.com.my
Date : 27 June 2002
Copyright : U R FREE 2 Use Anypart of this CODE .. 
			Include my name as Credit if NOT Forgotten..
--->
<!---
 MYDAY - Set day of week U want to list
	1 - Sunday
	2 - Monday
	3 - Tuesday
	4 - Wednesday
	5 - Thursday
	6 - Friday
	7 - Saturday
	
	Please modify accordingly to suit ur requirment
--->
<cfparam name="myyear" default="2002"> 
<cfparam name="myday" default="7"> 
<!---Set date by ur self make sure it start with first of the month--->
 <cfoutput>
	<cfset startdate = "#myyear#/01/01"><cfset enddate = "#myyear#/12/31">
 </cfoutput>
 
	<!---Assign current date with start date--->
 <cfset currdate = startdate>
 <cfoutput>
 <CFSET intTOTALDAYS = (DateDiff("d", startdate, enddate))+1>
 Total days = #intTOTALDAYS#<br>
 <cfset currmonth=month(currdate)>
 <cfset currweek = 0>
 <cfloop index="daycount" from="1" to="#val(intTOTALDAYS)#">
 <!---IF current month IS changing---> 
 	<cfif month(currdate) NEQ currmonth>
	 ---------------------------------<br>
	 <!---Assigning variable with current month---> 
<cfset currmonth=month(currdate)>
	 <!---Reset current WEEK--->
	 <cfset currweek = 0>
	</cfif>
	<!---Detecting current day is Saturday--->
 	<cfif dayofweek(currdate) IS #myday#>
	<!---Detecting the day is early of month If YES reset current week--->		
	<cfif day(currdate) IS 1>
		<cfset currweek = 1>
	<cfelse>
		<!---If NOT increase current week--->
		<cfset currweek = currweek +1>	
	</cfif>
	 <!---DETECTING Wether current week is 1 OR 3--->
	 <cfif currweek IS 1 OR currweek IS 3>
	 	<!---You may assign to list if you want--->
	 Saturday=#dateformat(currdate,"dd mmmm yyyy")# #currweek#***
	 </cfif>
	</cfif>
	<!---Increase next day cycle date--->
	<CFSET currdate = DateAdd("d", 1, currdate)>
	</cfloop>
	</cfoutput>


Other 1 submission(s) by this author

 


Report Bad Submission
Use this form to tell us if this entry should be deleted (i.e contains no code, is a virus, etc.).
This submission should be removed because:

Your Vote

What do you think of this code (in the Intermediate category)?
(The code with your highest vote will win this month's coding contest!)
Excellent  Good  Average  Below Average  Poor (See voting log ...)
 

Other User Comments


 There are no comments on this submission.
 

Add Your Feedback
Your feedback will be posted below and an email sent to the author. Please remember that the author was kind enough to share this with you, so any criticisms must be stated politely, or they will be deleted. (For feedback not related to this particular code, please click here instead.)
 

To post feedback, first please login.