If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. |
|
|
Thread Tools | Display Modes |
#1
|
|||
|
|||
How to find number of Fridays in a month or in a particular interval date
I want to count that how many friday is there in a month
or from a date field to another date field for example : Form!Text1 = 15-07-2004 Form!Text2 = 14-08-2004 I want to find that how many fridays were there inbetween the above two date on a seprate field on that same form. |
#2
|
|||
|
|||
Irshad,
This small function in VBA will calculate the number of Fridays between any two dates: Function Count_Fridays(StartDate As Date, EndDate As Date) Dim FCount As Long Dim tDate As Date Count_Fridays = 0 tDate = StartDate If Weekday(StartDate, vbFriday) 1 Then tDate = tDate - Weekday(StartDate, vbSaturday) + 7 End If Do While tDate = EndDate Count_Fridays = Count_Fridays + 1 tDate = tDate + 7 Loop End Function Paste the code in a general module, then on your form put the following in the controlsource of a textbox to display the number of Fridays: Count_Fridays([Text1], [Text2]) Use a macro or a line of code like: Me.ControlName.Requery (change ControlName to the avtual name of the control displaying the number) in the Before_Update event of both Text1 and Text2 to requery the textbox every time one of the two dates changes. Do the same with the form's On Current event, so it is requeried when you scroll through records. HTH, Nikos "Irshad Alam" wrote in message ... I want to count that how many friday is there in a month or from a date field to another date field for example : Form!Text1 = 15-07-2004 Form!Text2 = 14-08-2004 I want to find that how many fridays were there inbetween the above two date on a seprate field on that same form. |
Thread Tools | |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Number of Mondays in month | Michael Noblet | Setting Up & Running Reports | 3 | July 28th, 2004 10:41 PM |
decipher log of scanpst.exe | km | General Discussion | 0 | July 18th, 2004 09:00 AM |
Aggregating Date Data into Weeks and Quarters | Roger | Running & Setting Up Queries | 3 | July 11th, 2004 05:56 PM |
Converting Text Month to Number | Earl Kiosterud | Worksheet Functions | 5 | October 13th, 2003 06:57 PM |