A Microsoft Office (Excel, Word) forum. OfficeFrustration

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.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Using Forms
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

How to find number of Fridays in a month or in a particular interval date



 
 
Thread Tools Display Modes
  #1  
Old August 26th, 2004, 12:52 PM
Irshad Alam
external usenet poster
 
Posts: n/a
Default 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  
Old August 26th, 2004, 02:05 PM
Nikos Yannacopoulos
external usenet poster
 
Posts: n/a
Default

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

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump

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


All times are GMT +1. The time now is 12:27 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.