How to know witch are the weekend days between two dates

I have to make a list of every weekend days between two dates.

Example (dd/mm/yyyy):
Field1: 01/01/2007
Field2: 15/01/2007

The result (on a listbox) I want are all the weekend days between those dates:
06/01/2007
07/01/2007
13/01/2007
14/01/2007

Any help?
0
Utf
4/2/2007 4:26:02 PM
access.formscoding 7493 articles. 0 followers. Follow

3 Replies
904 Views

Similar Articles

[PageSpeed] 15

Assuming i have two fields on a form that contain the beginning and ending
dates (FirstDay, LastDay), a listbox (list0)  and a command button to compute
them, the code would looke like this.

Private Sub Command2_Click()

Dim strday As String
Dim intIndex As Integer
Dim intNbrDays As Integer
Dim newdate As Date

List0.RowSource = ""
intNbrDays = DateDiff("d", FirstDay, LastDay)
For intIndex = 0 To intNbrDays
   newdate = FirstDay + intIndex
   strday = DatePart("w", newdate)
   If strday = 1 Or strday = 7 Then
      List0.AddItem Item:=newdate
   End If
Next intIndex
End Sub


Nuno Guerra wrote:
>I have to make a list of every weekend days between two dates.
>
>Example (dd/mm/yyyy):
>Field1: 01/01/2007
>Field2: 15/01/2007
>
>The result (on a listbox) I want are all the weekend days between those dates:
>06/01/2007
>07/01/2007
>13/01/2007
>14/01/2007
>
>Any help?

-- 
Message posted via AccessMonster.com
http://www.accessmonster.com/Uwe/Forums.aspx/access-formscoding/200704/1

0
NthDegree
4/2/2007 5:54:17 PM
You can use code such as this to determine the date value of the
Sunday prior to the current date:

SunDVal = CLng(Date) - Weekday(Date) + 1

If you're familiar/comfortable using date values based on the epoch
used by Access (Windows & Office actually), you can then add and
or subtract 7 to move from one weekend to another.

Hope this gets you started.

Bill



"Nuno Guerra" <NunoGuerra@discussions.microsoft.com> wrote in message 
news:243B5554-33F4-409A-B439-3C068797B057@microsoft.com...
>I have to make a list of every weekend days between two dates.
>
> Example (dd/mm/yyyy):
> Field1: 01/01/2007
> Field2: 15/01/2007
>
> The result (on a listbox) I want are all the weekend days between those 
> dates:
> 06/01/2007
> 07/01/2007
> 13/01/2007
> 14/01/2007
>
> Any help? 


0
Bill
4/2/2007 6:02:57 PM
This is air code but should pull a list of Week-end dates between 2 inputs

Function FindWeekEnd(dtDate1 As Variant, dtDate2 As Variant) As Variant

    intDays = DateDiff("d", dtDate1, dtDate2)

    dtDate = dtDate1
    For I = 1 To intDays - 1 Step 1
        dtDate = DateAdd("d", 1, dtDate)
        If Weekday(dtDate) = vbSaturday Or Weekday(dtDate) = vbSunday Then
            FindWeekEnd = FindWeekEnd & "," & dtDate
        End If
    Next I

    FindWeekEnd = Right(FindvWeekEnd, Len(FindWeekEnd) - 1)

End Function

-- 
Hope this helps,

Daniel P


"Nuno Guerra" wrote:

> I have to make a list of every weekend days between two dates.
> 
> Example (dd/mm/yyyy):
> Field1: 01/01/2007
> Field2: 15/01/2007
> 
> The result (on a listbox) I want are all the weekend days between those dates:
> 06/01/2007
> 07/01/2007
> 13/01/2007
> 14/01/2007
> 
> Any help?
0
Utf
4/2/2007 6:08:07 PM
Reply:

Similar Artilces:

Formula help, compare amount in two cells
Thanks in advance for any help: I want to compare the amounts in two separate columns. If the amount in cell c4 is less than the amount in cell c6, then subtract c4 from c6 and put the result in c5 and color it red. I know this is simple but I just can't get it to work. Any help is really appreciated. In C5 put =IF(C4<C6,C6-C4,0) Then click on C5 and do Format > Conditional Format > Formula Is > =$C$5>0 and select Format > Patterns > and select Red color > OK > OK Vaya con Dios, Chuck, CABGx3 "29kilo" <anonymous@discussions.microsoft.com...

Day Validation code
Hello, I am looking for some help for my data entry form. In the form there is a combo box, which is used to enter date ("cboLongDate"). The date format is "Wednesday, June 13, 2007" . I need to confirm the day is Wednesday or not before the user click on add data or close form. The important thing is day (ie "Wednesday") not the date as Wednesday comes every week. If the selected day is not "wednesday" a message box should pop up saying the day selected is incorrect while closing or adding data so that user can get a chance to correct it. Thanks in adv...

Multi day meeting with different times
We have a process that has a weekly set of meetings that are: M 9:00 AM - 3:00 PM T-F 9:00 AM - 12:00 PM I'm looking for a way to do this with one meeting request. A couple of ways to do it with 2, but I'd like to just have 1 request if it's possible. We have Office 2003. Thank you! Peter -- Have a great day everyone! It's not possible with one. -- Diane Poremsky [MVP - Outlook] Outlook Tips: http://www.outlook-tips.net/ Outlook & Exchange Solutions Center: http://www.slipstick.com/ Outlook Tips by email: mailto:dailytips-subscribe-reque...

Query that will look for duplicate in two tables.
I have two tables that were originaly Excel tables and imported them into Access. Import went well. Both tables consist of columns named - Name, Department Number, Department Name, and Employee ID. I need to compare the two tables and have Access give me the NON duplicates. I ran a Find Unmatched Query using name in both tables. The results showed almost as many records as are in the original two tables. What I noticed it found in one table Smith, John and Smith,John. These are the same people but one person typed the name with the last name and comma space while the other pers...

Need "Payment Date" in register, not entry date
I'm on 2005. In previous versions, I had an option to show the payment date in the register but I can't find it in this version. Is it still available? If so, how do I set it? Thanks, Brad ...

Sumproduct to count between two dates
Using Excel 2003 there are dates in F3:F19 and procedures, such as THR, in G3:G19 on the sheet East 2010. On a second sheet in the workbook I need to count the number of 7 different procedures for each quarter. Based on feedback found in other questions I have come up with this formula: =SUMPRODUCT((('East 2010'!$G$3:$G$19="THR")*'East 2010'!$F$3:$F$19>=DATE(2010,4,1)*'East 2010'!$F$3:$F$19<=DATE(2010,6,30))). I have tried different variations but am missing something as it is not function properly. Hi, Try this and note the different...

Date calculations #2
I'm looking for a way to calculate if a date is between to other dates then one thing, if not another thing. The situation is I rent a cabin year round. The pricing between Jan. 1 and May 25 is one Price, the rest of the time the Pricing is another . Gourd and Bob I knew I'd be back soon... LOL On Wed, 17 Oct 2007 08:03:01 -0500, "Barry" <candeman55@hotmail.com> wrote: >I'm looking for a way to calculate if a date is between to other dates then >one thing, if not another thing. > >The situation is I rent a cabin year round. The pricing between ...

HELP! I KNOW U KNOW HOW TO DO THIS....
i was told there is a way to make certain letters equal numbers. EX. BREADNMILK is 1234567890 / B=1 R=2 and so on. This is so each product has a digit code for the price. EX. EDB = $3.51. I don't know how to do that but my boss said it's possible....THANK-YOU! I have an idea, but I'm not sure I understand what you really want, so I hate to waste the time to produce it. Could you give a few more examples? What are you doing with the data once you figure out a way to make this work? Why BREADNMILK? Is that just an example? You'll use just one word? You're trying to obscu...

What date is my IMF updated to?
Is there a way to determine to what date the IMF is updated? On this Exchange 2003 SP2 machine with IMF V2, there are occasional updates, such as "Update for Intelligent Message Filter for Exchange Server 2003: 2006.09.14." Is there some way to see that the IMF is using this 9/14/2006 update? Thanks. This should help. http://msexchangeteam.com/archive/2005/12/14/416070.aspx "Julie" <julie@somewhere.org> wrote in message news:O33sIcR5GHA.3560@TK2MSFTNGP03.phx.gbl... > Is there a way to determine to what date the IMF is updated? > > On this Exchange 2...

Limit the data selection based on two fields?
Hello, I have a data entry form where user input the data. Within the data fields, I have field call Item, Side, sequence field where any combination of these 3 fields are unique. What I would like to achieve on the sequence field is limit the selected based on selection of Item and Side. This is to prevent user from inputting wrong values on that field. Any help is appreciated. Example fields: Item Side Sequence 11A1300-1 1st side 50 11A1300-1 1st side 100 11A1300-1 1st side 200 11A1300-1 1st side 400 11A1300-1 1st side ...

OWA jumping mouse
I have two computers on my network that are having an interesting issue. When they are creating a message and typing away in the body of the message, randomly when they hit a key, any key, they system will act as if the mouse was clicked. If the mouse is over the send button, it would have sent the email. If the mouse was over the start button, the start menu would have come up. Where ever the mouse was left at, it will act as if it was clicked. It is very random but often. This only happens in OWA, not in outlook or any other place. Both systems are running XP pro SP2 with IE 6 SP2. ...

It's Conditional Formatting, Jim, but not as we know it...
Hi, Is there any way of producing the same as a conditional format on a cell (ie. chenge fill and font colours according to a calculated value) but for more than three (four, if you count the default) values? TIA Dave An example '----------------------------------------------------------------- Private Sub Worksheet_Change(ByVal Target As Range) '----------------------------------------------------------------- Const WS_RANGE As String = "H1:H10" '<=== change to suit On Error GoTo ws_exit: Application.EnableEvents = False If Not Intersect(Targe...

Do You Know???
Hi... Where to get personal / business loan? How to settle your debt? Where to invest? Monthly Profit 20%? One time investment only? Setup your own business & growing income? The Beneficiary Bank is Barclays Bank? Just only need USD1070 for Financial Freedom? 300% Profit,10%Commission,5% Bonus,1% Revenue & 0.01% Daily Profit Payout!! ---------------------------------------------------------------------------= =AD=AD----- Get me online at : E-Mail /Yahoo Messenger,my ID : sallehes[at]yahoo.com Change [at] to @ If you never take the chance, you will never have the chances. >From O...

Excel bar graph with two axes
I'm trying to set up a chart with four series on two Y-axes (two series on each). I can do that, but I get the two series of one axis superimposed over the two series of the other axis. Is there a way to have all four bars display next to each other (the way they do if it's just one axis) but scaled to the two axes? I'm guessing you want something like this http://www.peltiertech.com/Excel/Charts/ColumnsOnTwoAxes.html "Ben-Head" <BenHead@discussions.microsoft.com> wrote in message news:8375E48D-2A95-4727-9D72-AAF2E6919992@microsoft.com... > I'm try...

Do you know this?
I gonna to purchase Joyfax Server. Do you have any idea about it? 'Joyfax - Fax Server, Fax software, Windows Fax Server, Network Fax Solution, Free Fax Viewer, Fax Broadcasting software' (http://www.joyfax.com) -- lenny66 Posted via http://www.vistaheads.com In article <lenny66.4cslw5@no-mx.forums.vistaheads.com>, lenny66.4cslw5 @no-mx.forums.vistaheads.com says... > What exactly would you imagine yourself seeing subject "Do you know this?" People usually ignore topics with unclear subjects. -- Poutnik The best depends on how the be...

Does any know how to add more columns in the NCAA Excel Tracker?
trying to add more columns in the NCAA Tournament Tracker but it won't keep the formulas correct. Any help Just what exactly is the/a "NCAA Tournament Tracker"? -- Regards, RD -------------------------------------------------------------------- Please keep all correspondence within the Group, so all may benefit ! -------------------------------------------------------------------- "NCAA Tourney Commissioner" <NCAA Tourney Commissioner@discussions.microsoft.com> wrote in message news:8020B969-D6D4-4857-96E4-3475D1F75DA6@microsoft.com... trying to add more ...

Earn $200 per day without a website
Tired of wasting your time & hard earned money on "intelligent" programs which promise to make you rich overnight? Then read on, because I am going to show you............. How I made over $2000 in just 10 days using a ridiculously stupid technique I stole from my own affiliate Click the following link to see the entire procedure explained step-by- step. http://www.showroute.com/odp I Got MY Own ATM. J http://www.showroute.com/odp Wilson. ...

do you know??
hi I have a problem I had made a programm deal with database I had created it manually by microsoft access. I want the programm make the database automatically when it run on every computer?? second did every computer run this programm have microsoft access ??? goodbye thank you ??? 1. You should just ship the mdb file with your program. 2. you don't need to have access installed on all the computers just the odbc/ado drivers for access. AliR. "mohaz" <mohaz14@yahoo.com> wrote in message news:1187291340.459954.57930@k79g2000hse.googlegroups.com... > hi >...

date format #18
Hi all, I have a spreadsheet containing lots of pivot tables. The source data contains date formulas in the following ways: =IF(FR5="","",TEXT(FR5,"yyyy-mm")) this returns dates like----- 2007-11 =IF(GM5="","",TEXT(GM5,"mmm-yy")) this returns dates like------- Nov-07 As a result, when I try to sort my pivot table data by date, the dates that are shown as Nov-07 are recognised as text therefore only allowing me to sort by alphabetical order. The dates that are like 2007-11, i am able to sort it by the earliest/latest dates. I...

Exchange and two domains
Good Day, I'm running exchange 2003, client of mine wants to have two domain names that exchange will host. They currently are setup with one domain, how do I add the second domain to exchange? Hi Ray This article should help you out: http://www.msexchange.org/tutorials/MF010.html -- Mark Fugatt Microsoft Limited This posting is provided "AS IS" with no warranties, and confers no rights. "Ray" <Ray@discussions.microsoft.com> wrote in message news:A43483B8-D36E-451F-BF89-C448C59D711E@microsoft.com... > Good Day, > > I'm running exchange 2003...

Don't want tasks in days.
Is it possible to stop LookOut 2003 from converting my tasks to days when I type in hours? It's SO annoying. Grrr. Thanks in advance. Cheers Vicky ...

I would like to know how to uninstall Outlook Express 6!
When I purchased my computer, it was installed with Outlook Express 6, and I don't use the program. I would like to know how to uninstall it. Please reply if you know how! If you are running Windows XP with Service Pack 1 or Windows 2000 with Service Pack 3 or 4, try going to the add/remove applet in the control panel. Choose Set Program Access and Defaults. Under the email section, uncheck the box to show the icon. (It will always remove the OE icon.) Note: If Microsoft Outlook is your default mail program, it will try to push newsgroup support to OE (started as a news only clien...

Problems using ReadXmlSchema to read two tables into ds
I am trying to load a DataSet from an xml file that has 2 tables in it. Any help would be great. Here is the C# code snipit on how I load it. Instead of geting a dataset with 2 table I am geting a dataset with 4 tables in it. All four tables have no rows. DataSet lds_working = new DataSet( "PB_TABLES"); ls_schema = MapPath("two_table.xsd"); lds_working.ReadXmlSchema(ls_schema); lds_working.ReadXml(MapPath("two_table.xml")); Here is the XSD <?xml version="1.0" ?> <xs:schema id="PB_TABLES" targetNamespace="http://tempuri.or...

Searching on date strings
Version: 2008 Operating System: Mac OS X 10.5 (Leopard) Processor: Intel I want to create a simple 2-row Gantt chart that compares dates in a column, 11-rows long with a date range across the top and populate the cells underneath the dates with a set of task #s that match the rows. For example if the first 3 tasks are all scheduled in Week 1, the cell under that date would show: &quot;1,2,3&quot;. <br><br>Other than an 11-nested 'IF' function, is there an easier way to do this? Not that I know of. You might have a look at a Pivot Table and see if you can ...

Using dates in formulas
How do I use dates in formulas? For example, I want to figure out how much interest a tenant has earned on their security deposit since they have lived here until now. I also want it to update itself daily according to the current day. Garfield As long as your dates are Excel dates (recognised as dates by Excel) it is just a case of using standard arithmatic. If your first date is in A2 you can use =TODAY()-A2 to give the number of days, months and/or years between the dates, by formatting the cell accordingly. HTH Andy. "Garfield" <wyngate@frontiernet.net> wrote in mess...