Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
  HOME    TRACKER    Visual Basic

Exclude Saturday & Sunday ?

Is there a kind of function while calculating interval between dates excluding Saturdays and Sundays ?Using DateDiff("d", x, y) I get the whole interval !!!

View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread
What Can I Do With Saturday And Sunday
Hi i have a datediff clausure to calculate the days between 2 dates i need to exclude the saturday and sunday in total days. How can i do that?

Saturday And Sunday
Hi Someone can help me

I want count between to date how many Saturday and Sunday (Or Weekend)



Help In Detecting Saturday And Sunday

i create a simple payroll system and it's almost done, i have one problem on how to detect saturday and monday in current pay period (1-15 or 16-31).
pls help i really appreciate your help. thanks in advance.

If Today Is Saturday Or Sunday Then...
Can some please provide a code snippet that accomplishes the following?:

If today's date = Saturday or Sunday then
'existing code here
end if

Thank you for your help!

How To Find Last Day(Saturday/Sunday) And Date Of A Week
How to find Last Day(Saturday/Sunday) and Date of a week

Listing Second Saturday
Hi all

I need to list all the dates of second saturday for two months from the date entered by user as input.

Does anyone know a short and quick method to accomplish this. there are many long methods but i need a short and simple one.


Last Saturday! (the Date, That Is)
What would be the best and easiest way to get the date of the LATEST saturday?

I thought of some code that I'm pretty sure would take way too many lines by not using the appropriate function.


Saturday's Between To Dates
Like you've got nothing better to do:

My situation:

Knowing a MIN DATE and a MAX DATE, how can you display all SATURDAY dates that fall between these two dates in say, a combo box? I am trying to make user pick a valid SATURDAY date.

Any suggestions. I know I could evaluate the date to detremine it's a Saturday, but I figured the way I described might be easier for the user.

Sunday Or Not
I am creating something like a year planner.

I need to know whether a given date (October 12, 2005) falls on a sunday or not

I searched in google, this forum and MSDN but couldn't find an answer

How Do I Find The Date Of This Saturday?
I'm a programming neophyte so needless to say I need some help on some
VB scripting.

I need to create some code to find what month it will be this coming
Saturday. I also need to do the same for the week # of the month this
Saturday. And finally, the Year of the month this Saturday.

Could someone help me with this?


HOw Could I Check It Is Sunday?
I am writing a payment program and every sunday , we have to pay twice. How could I write a program that If today is Sunday then the program should doble of payment. Thank in advanced =)

Sunday Teaser
hi All interested
I have attached a sample project
Its giving me a lot of headaches
Basic Problem
Data in Datagrid not saving
Do this
1. Run the project
2 .Press Show form
3 .Press Show DAta
4. change the data in any of FLD1,Fld2 etc (Not KeyID as its primary Key)
5. Press Enter
The value on screen has changed
6. Click Hide Data
7. Click Show Data again

The value reverts back to the original value
To make it work you have to
do same as above up to no 5
Then press Down Arrow
Click hide data
click show data
Now the update is permanent
Can anyone solve this
Driving me mad
Cheers in Advance

Third Sunday Function
What I want to do is, when the date-type variable "mdbtGameDate" changes, run a function to find if the current date is the third sunday of the month, and if so, set the "CurrentVar" boolean-type variable to true. How would I do this?

Thanking you in advance...

Getting The Date For Next Sunday ??
I'd like to find a way to get the date for the next Sunday from the current date.  How would I go about this?

DateTime Property-How To Determine The 1st And 3rd Saturday?
How to determine the 1st and 3rd Saturday?
I want to apply special condition to the 1st and 3rd saturday of every month ,but not all saturday.
Anyone know how to write the code?
thx a lot...

Make Week Start On Saturday
Hi, I have a Report in Access that contains a field called Seminar Date, among other fields. The report is grouped by Seminar Date using the group by week option in the Report wizard of Access. However, the week starts on a Sunday according to Access. Is it possible, using VB or any other method, to have the week start on a Saturday instead?

Thanks for any help!

Data Report Question (I Know It's Saturday, But I Need Help Bad!)
Is there any way for me to display info on a data report like this?

FirstName LastName


Currently I'm getting this:
FirstName LastName


FirstName LastName


FirstName LastName


Does anyone know how I can make my report look like the first example?

Thank you!!!!

How To Find The Previous Saturday's Date
I know it is possible, but is there a quicker way and/or
trick to find the previous Saturday and/or a particular day?

Any advice would be greatly appreciated.


Add Sunday Dates Into List
how would i go about adding the next four sunday dates into a combobox?

Get The Date Of The First Sunday Of The Week

I will pass the week num ( 1/2/3/4/5) and week day(1/2/3/4/5/6/7)
for a date varaible.

I need to get the date of the first sunday or second sunday or first monday
or second monday of the month.
As per the parameters passed above , I need to get the date values.
Any VB functions to get this.

Pls let me know reg this ..


Two Quick Questions For Sunday
Hello all.
Just a quick question. If I declare a Variant type variable, should I set it = nothing when I am finished with it? I don't get an error when I do this . I want to make sure that all resources are released.

Second quick question. If I create a ComboBox control at run time, can I make it have a particular index number? I am using the index number to tie the combo to a particular column in an MSHFlexGrid. The problem is that the number of combo's needed is increasing as the programme gets more complex and I would like to reduce the 'weight' if I can.


How To Find The FIRST Sunday Of EACH Year?
How in the world can I do this?

Determine Last Sunday Of Month ?
Guys, Do you have any piece of cide to determine the last sunday of any given month ?
Actually I want to find the day the daylight time chnages dynamically. Since we know that it is on the last sunday of cotober,If I could find the last sunday of any given month in a given year I can do it.
Any idea folks ?


Combobox Populated With Sunday Dates
I have a VB 6.0 form used for Crystal report selection criteria. I need 1 combobox that will display Sunday (start of week) dates for a selected year. I will then populate the 2nd text box with the Saturday (end of week) dates.

I am not a VB programmer and have had little experience. Need some direction on where to start.

Thanks in advance.

How To Get The Date(Moday - Sunday) Info


Any solution given if i would like to get next week "moday- sunday".

For Example :
Today is 08/08/2008 - wednesday
Next Week 24/08/2008 - Moday

Mon(24/08/2008)| Tue(25/08/2008)| Wed(26/08/2008)|

thanks for any reply.

VbForum ... is the best for vb...

Recognizing Sunday (RESOLVED Thanks DaVBMan You Da MAN! )
Ok, now that we have the dateadd function figured out, I was wondering if anyone knew of a short script for the computer to recognize sundays date and then pend it +1 day if it falls on Sunday. . . .

Example. . . .

I have a customer who said they can do (xx activity) in 3 days, but in 3 days the day will be sunday, but instead of manually changing it to 06-21, what I would like is to get VB to recognize the day and then +1 it to Monday?

sound complicating? It would basically work in conjunction with this coding:

Dim c As String
        c = DateAdd("d", 2, Now) "If date = vbSUNDAY then DateAdd'("d", 1, Now)
        c = Format(c, "mm/dd")

Edited by - Bryan Duncan on 6/15/2004 6:15:38 PM

Saturday Summer Doldrums Graphic Effects Grabbag
Well it looks like the forum is into the yearly Saturday Summer Night doldrums.

I've recently come out of the doldrums myself (and "re-centered' a bit after my dark thoughts thread) so I want to throw myself into doing something...

You know it's so frustrating to sit around and wait for someone to post an interesting question about some special or unique graphics technique/effect.

Instead, you get an endless stream threads from newbies where you end up giving some canned answers, like --yes, you need to turn on AutoRedraw, use Bitblting, and, most certainly, a memDC backbuffer would probably help, etc.

While I've been patiently waiting (for months...or sometimes even years), I've had lots of opportunities to surf the net looking for new and unique ways of achieving certain types of graphic effects.

So that's what this thread is basically about -- experimental pixel manipulations, figuring out different ways to use/adapt/evolve code to do graphics-related things that maybe hard to do.

Although all attachments provided will be "working" code, the programs themselves have shortcomings of one sort or another. All could probably use more optimization or even re-work if someone can figure some clever workarounds to speed things up.

I've probably got enough stuff sitting on my hard drive to fill the next eight Saturdays, but anyone else who wants to post experimental "cutting edge" graphics routines...well.. I certainly can't stop you.

I am interested in seeing code for things like doing controlled, fast, per pixel alphablended blurring, dragging per-pixel alphablended sprites, multi-layer gradients-to-transparency, gradients shaped along complex curves, any 3D modeling that lets you do GDI-based (non-DirectX/non-OpenGL) mouse controlled sub-divison deformation, etc.

Today (this evening) I want to start out with Gourand and Phong shading.

It's probably hard to believe, but after a million posts, no one (not a single person) has even posted any Visual Basic code to accomplish either type of shading (although they've been mentioned in a few threads if you do a search). It's time to rectify this glaring omission.

The attached demo is based on code found in Rod Stephen's excellent book on Graphics Programming -- I decided to morph/merge (Frankenstein) a few samples together to compare and contrast the different pixel shading methods. It's was an excellent learning experience, but even with an upgrade of the code (from using Pset to using SetPixel) the rendering is still slow.

Maybe someone will attempt a DMA makeover, but I think the main slowdown is not in the drawing/rendering but in all the calculations that need to be done -- using matrix transformations and vertex normals to do the plotting of points and calculation necessary for the "smoothing" of colors

Hopefully someone might find it mildly interesting...if not, check back..I'll have something else to post here next week.

I have a VB code that finds hyperlink field paths from Ms Word document. Code tshows the whole path, including the filename, too. But the code should leave the filename out and show only the path.
Filenames are always the same, so I could specify that foo.xls, baz.xls and bar.xls are not shown.
How I can do that? Is there any EXCLUDE - command in VB and how it works.

A Simple Question To Help A Tired Frank N Beans Working On A Sunday
Hello (again!)

I have a userform called frmSpecReq which has 18 CheckBoxes on it.

I want the captions of the CheckBoxes to change to match the contents of Options!B203:B221, without Excel moving from the current Tab (Quote Register).

How can I get get the first CheckBox (chkSpecReq1) caption to change to Options!B203?

Thank you (from a Numpty)


Exclude Pattern

Im making a small program that 'cleans' the desktop from any recent downloads or other files (it moves the files to another directory).

The program selects the file from a Filelistbox, however i don't want to move the links (*.lnk) so how can I use the pattern of the filelist to exclude this one? or is that impossible?

My current pattern is *.* and i want it to see all files besides the links..

Thanks in advance,


Exclude Values
Hello, i have a small problem.
I'm making a program(macro) that goes trough a number
of cells (in excel, but that's not very important).
I have a for next loop:

For i = 3 to 97 code


But...there are a few numbers that should not be
used. I tried something like:

For i = 3 to 97
If i <> 10 or i <> 18 or i <> 26 or i <> 34 etc... Then code
End If

but that doesn't work.
Maybe one of you knows an efficient way to exclude
certain values from a for next loop?

Exclude Public
Is there a way to tell a subroutine or function not to use any public variables? So that any variable that happens to be public will be a local scope only?

How To Exclude A String
I want to exclude a string in a caption if it includes a certain word.. how would I do that? I want to exclude the WHOLE string Thanks

Exclude Letters
hi y'all
i'm pretty new to VB. i'm trying to improve and i have a question:
i have a label and a comamnd button.
when i press on the command button, a msgbox appears with the square root of the number that i entered in the label. this only works if i enter numbers in that label, if i enter letters or other carachters, it bugs.
now how can i make appear a msgbox saying "You must use numbers" if i don't enter numbers in the label?
thanx in advance for your help

How To Exclude Some Files In VB?
As we know, * is the wildcard for every file. But how to exclude some specified files among all of the files specified by *? Thanks for your inputs.

Exclude Orders In SQL - HELP
This question is not specific to Visual Basic, but because VB apps usually have a database behind them, I thought this would be a good place to post my question.

I am using SQL Server 7 and am trying to run a simple query that will exclude orders which include a particular product. What is happenning is that my results include the orders with the product in question, just not including that product. I don't want that order to be included at all.

Here is what I am using:
select, o.orderdate, od.productid
from vworders o, vworderdetails od
where = od.orderid
and od.productid <> 751
and o.orderdate = "7/16/02"
order by

If order 301762 is placed on 7/16/02 and includes products 101, 144, 751, and 852, I do NOT want the order to be in my results because it includes 751 in the order, yet it is being returned in my results (the order is being returned with the 3 other products).

Simple, I'm sure. It's been a while and is driving me crazy. This is what happens when you're out of programming for a while. Any and all suggestions are greatly appreciated!

Thank you!

Setup Any DLL's To Exclude ?
Does anyone know of a list of at least a few large setup files
that can be eliminated from the distribution process.
Any of the common ones that virtually all users machines would
most likely have on there computer.
6mb to 8 mb distribution size is getting out of hand for a 400 to 600 kb program !
Here's a few common big ones ??


Exclude Cell From Formula
I have a cell that is the AVERAGE of a range of cells. This value will be used in a graph. I want to enable the user to select one or more of the cells in the range that is averaged, and be able to exclude their value from the AVERAGE calculation, without deleting the data from the worksheet. I was thinking to change the formatting of the cell, then making the formula something like "if the cell in range A1:A15 is not RED, then AVG(A1:A15)" to exclude any cells that the user has made red.

I'm sure you get the idea. How do I do such a thing?


Filter To Exclude Data
Hi All,

I have an inputbox for users to enter multiple store numbers. What I need to do is actually filter out the store numbers that was entered into the inputbox
my code so far is:

'Inputbox to filter out new stores
Newstore = InputBox("Enter New Store Numbers seperated by a space", "Enter New Stores", "119 120")
x = Split(Newstore, " ")
For i = 0 To UBound(x)

Range("A1").CurrentRegion.AutoFilter Field:=2, Criteria1:="<>" & Array(x) _
, Operator:=xlFilterValues
Next i
For some reason it doesnt like the "<>" & Array(x) Any ideas?


Exclude Sheet From Loop +
I'm having a senior moment and cannot remember the name of the person that gave me this great macro late last week otherwise I would give him credit for it.
Still I need all the help I can get in altering the code to do an extra two things.
a) to exclude Sheet1 from the "loop" thus excluding same from the consolidation of all the sheets in the workbook.
b) to exclude Row1 in all the other Sheets (I use Row1 for headers)
Thank you.

Here is the macro:

Sub Consolidatesheets()

Dim wrk As Workbook 'Workbook object - Always good to work with object variables
Dim sht As Worksheet 'Object for handling worksheets in loop
Dim trg As Worksheet 'Master Worksheet
Dim rng As Range 'Range object
Dim colCount As Integer 'Column count in tables in the worksheets

Set wrk = ActiveWorkbook 'Working in active workbook

For Each sht In wrk.Worksheets
If sht.Name = "Master" Then
MsgBox "There is a worksheet called as 'Master'." & vbCrLf & _
"Please remove or rename this worksheet since 'Master' would be" & _
"the name of the result worksheet of this process.", vbOKOnly + vbExclamation, "Error"
Exit Sub
End If
Next sht

'We don't want screen updating
Application.ScreenUpdating = False

'Add new worksheet as the last worksheet
Set trg = wrk.Worksheets.Add(After:=wrk.Worksheets(wrk.Worksheets.Count))
'Rename the new worksheet
trg.Name = "Master"
'Get column headers from the first worksheet
'Column count first
Set sht = wrk.Worksheets(1)
colCount = sht.Cells(1, 255).End(xlToLeft).Column
'Now retrieve headers, no copy&paste needed
With trg.Cells(1, 1).Resize(1, colCount)
.Value = sht.Cells(1, 1).Resize(1, colCount).Value
'Set font as bold
.Font.Bold = True
End With

'We can start loop
For Each sht In wrk.Worksheets
'If worksheet in loop is the last one, stop execution (it is Master worksheet)
If sht.Index = wrk.Worksheets.Count Then
Exit For
End If
'Data range in worksheet - starts from second row as first rows are the header rows in all worksheets
Set rng = sht.Range(sht.Cells(2, 1), sht.Cells(65536, 1).End(xlUp).Resize(, colCount))
'Put data into the Master worksheet
trg.Cells(65536, 1).End(xlUp).Offset(1).Resize(rng.Rows.Count, rng.Columns.Count).Value = rng.Value
Next sht
'Fit the columns in Master worksheet

'Screen updating should be activated
Application.ScreenUpdating = True
End Sub

Exclude Previous Data In SQL
Hi All. I need to find a way to exclude data I've already looked for. I've got a database with data for various plants in it. Fields are [Plant Name], [Quantity], [Gallon], [B&B Size] and [Unit Cost]. I'm trying to add up the quantities and cost for each plant, treating plants with the same name but different sizes as different equations. For instance:

Name Quantity Size Cost

Plant 1 | 10 | 3 | $10
Plant 1 | 4 | 3 | $10
Plant 1 | 5 | 7-10 | $10

When adding up the data, I should get

Name Quantity Size Cost

Plant 1 | 14 | 3 | $20
Plant 1 | 5 | 7-10 | $10

The relevant code I've got is:

Public Sub New_Plant_Inventory()

Set mCnn = New ADODB.Connection
Set mRst = New ADODB.Recordset

If frmReports.cboYear.ListIndex <> 0 Then
intYear = CInt(frmReports.cboYear.Text)
intYear = Right(Format(Now, "Short Date"), 4)
End If

strSql = "SELECT * FROM tblPlants " & _
"WHERE Year([Job Date]) = " & intYear & ""

With mCnn
If .State = adStateClosed Then
.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:LandscapeLandscape.mdb;Persist Security Info=False"
End If
End With

With mRst
.ActiveConnection = mCnn
.CursorLocation = adUseClient
.CursorType = adOpenForwardOnly
.LockType = adLockOptimistic
.Open strSql
intNum = mRst.RecordCount - 1

'Max visible records on the form is 37
If intNum > 37 Then
frmPlantMonth.cmdNext.Visible = True
End If

ReDim strPlant(intNum)
ReDim intQuant(intNum)
ReDim intCost(intNum)
ReDim intGallon(intNum)
ReDim strBB(intNum)
ReDim strSize(intNum)
For I = 0 To intNum

'stores data in variables
strPlant(I) = mRst![Plant Name]
intQuant(I) = mRst![Quantity]
intCost(I) = FormatCurrency(mRst![Total Cost])

'two types of size differentials possible - gallons or B&B
If mRst![Gallon] = 0 Then
strSize(I) = mRst![B&B Size]
strSize(I) = mRst![Gallon]
End If
Next I
I = 0

strSql1 = "SELECT * FROM tblPlants " & _
"WHERE Year([Job Date]) = " & intYear & _
" AND [Plant Name] = '" & strPlant(I) & "'"

.Open strSql1
For I = 0 To .RecordCount

'If there is a "-" in the size, it is a B&B size, not a gallon
If InStr(strSize(I), "-") <> "0" Then
strBB(I) = strSize(I)
Else 'If not, it is a gallon
intGallon(I) = strSize(I)
End If

'If the size is determined by gallon then get data for plants with gallon
' as the size
If strBB(I) = "" Then
strSize(I) = intGallon(I)
strSql = "SELECT * from tblPlants WHERE " & _
"[Gallon] = '" & strSize(I) & "'"
'If not, then look for plants with B&B as the size
strSize(I) = strBB(I)
strSql = "SELECT * from tblPlants WHERE " & _
"[B&B Size] = '" & strSize(I) & "'"
End If


.Open strSql

' I need code here to check to see if I have already added
' up the data for this size - if so, move to the next record until
' I get to one with a different size than I've already gotten data for

A = 0
B = 0
C = 0
D = 0

Do Until .EOF
A = mRst![Quantity]
C = mRst![Unit Cost]
B = A + B
D = C + D
A = 0
C = 0


intQuant(I) = B
intCost(I) = D

frmPlantMonth.lblPlantName(I) = strPlant(I)
frmPlantMonth.lblUsed(I) = intQuant(I)
frmPlantMonth.lblSize(I) = strSize(I)
frmPlantMonth.lblJob(I) = FormatCurrency(intCost(I))

Next I
End With

Set mCnn = Nothing
Set mRst = Nothing

End Sub

Once I've gotten the information for Plant 1 with a size of 7-10 for instance, I want to exclude that information from further queries. Only look for plants with sizes different than what I've already gotten data for. Any help?

Exclude '0''s From Average Calculation

I've got stuck in writing a query in SQL server and wonder if someone knows the answer to my problem.

The code below forms my query.

I would like to work out the average 'OEcost' but not include 0's in that calculation. The SQL below will exclude those records with a 0 completely from the results but this is not what I want. I would like to include the records with a OEcost of 0 in the count but not include them in the calculation.

Can anyone help me with this.

I tried to combine another view for the cost calculations and then join the 2 but becuase I have over 2million records in the table this took far too long.



SELECT TOP 100 PERCENT COUNT(*) AS Expr1, dbo.tblEstimateParts.OEpartDescription, dbo.tblEstimateParts.OEpartRef, AVG(dbo.tblEstimateParts.OEcost)
AS Av_RRP, dbo.tblEstimateMain.DateInToUs
FROM dbo.tblEstimateParts INNER JOIN
dbo.tblEstimateMain ON dbo.tblEstimateParts.MainKey = dbo.tblEstimateMain.MainKey
WHERE (dbo.tblEstimateParts.OEcost <> 0)
GROUP BY dbo.tblEstimateParts.OEpartDescription, dbo.tblEstimateParts.OEpartRef, dbo.tblEstimateMain.DateInToUs
ORDER BY dbo.tblEstimateParts.OEpartDescription

How To Find And Exclude A CD Unit...?
Hello !

How do I identify a CD unit from other drives to avoid any use of it when create a directory in a program ?

I can exclude the CD unit if there is no CD in it, when pick the path in a drivelist ! Then it will show up as unavailable. But you'll never know from time to time if the user have...

Thanks for any info...


Exclude Checkbox On Listview?
Hi! I just like to know how to exclude check box on listivew background, when I try to set listview background, I couldn't see the checkbox. but when I load data it shows checkbox... tnx in advance....

File Listbox... Exclude?
Is there a way to exclude types in the filter in a filelistbox?

like <> *.log ?

Exclude Text In String Help
I want to display a winamp song into label... but when stopped it shows


I want to remove that, how would I go about it?

Info-Zip With Exclude Files?
Hi all,

I'm trying to get a simple backup program written for my work. I checked out and had a look at their zip wrapper class for the Info-Zip dll. It works great for zipping files recursively to zip entire directories and their sub-directories at a time.

My issue is that I need to be able to exclude certain files or sub-directories that are not important to save. The only exclusion mechanism I can see while perusing the dll is an exclude files older then X date. Unfortunately, that does not help me much.

Anyhow does anyone know how to get at some sort of hidden exclusionary flags, or other zipping algorithms that permit exclusion of unwanted files. Has anyone written this sort of functionality in themselves, and if so, I'd love some suggestions.

Does anyone know how to exclude unwanted files from a recursive zip is the crux of my issue.

I'm writing this in VB6 with W2K systems being the boxes that will run it.

Thanks in advance!

How To Exclude The Runtime Files
Is there a way to compile a VB program so it won't need the VB6 runtime files. It's for a small app that is to be autorun from a CD?


How To Exclude Custom Objects?

I've developed an Addin for Outlook. My Problem is, that if other applications create objects in Outlook (i.e. Faxmaker etc.) they may not have the methods / functions that I check. Example:

' If an object is added to the deletedItems Folder
Private Sub myDeletedItems_ItemAdd(ByVal Item As Object)
On Error GoTo DelItem_Add_Err
' ...
If Online Then ' Check, user func.

If Item.Class = 26 Then
' 26 -&gt; appointmentItem
Here an Error is generated if the item has no class-method. Ok, this is correct, but how can I write a function to exit the sub if an item fires the event that does not have this method?
Would really appreciate some ideas (even more some Code)

have a nice day,


Copyright 2005-08, All rights reserved