Hi. I am a novice user. I am using the datediff function in a query. I am trying to calculate the number of week days between two dates. When I use "m" as the interval, the number of weeks is returned. When I use "d" or "y" as the interval, the number of days is returned. What kind of calculation can I add to the statement to only count the number of week days? Is this possible?
I was thinking I might have to run a query on a query and put in a formula that somehow subtracts 2 days from every 7. The next problem would be if there were only 6 days. Then I would only want it to subtract 1 day.
thanks in advance for your help.
7 5955
An interval of “m” should give you months, not weeks! The following site has 2 different functions for calculating week/work days, one that does just that and a more complicated one that allows for the exclusion of certain holidays. Calculating Work/Week Days
Welcome to TheScripts!
Linq ;0)>
An interval of “m” should give you months, not weeks! The following site has 2 different functions for calculating week/work days, one that does just that and a more complicated one that allows for the exclusion of certain holidays. Calculating Work/Week Days
Welcome to TheScripts!
Linq ;0)>
Thank you. Yes, I did mean "w" as the interval. Where/how do I enter the code in a query builder?
Denburt 1,356
Recognized Expert Top Contributor
The link he provided you with should do what you need. You would place the code into a module in VBA then in the query you can use something to define the field name and it would look something like this:
NumberOfWeekDay s:WorkingDays(S tartDate, EndDate)
This should give you the results you need let us know how it goes.
The link he provided you with should do what you need. You would place the code into a module in VBA then in the query you can use something to define the field name and it would look something like this:
NumberOfWeekDay s:WorkingDays(S tartDate, EndDate)
This should give you the results you need let us know how it goes.
Thank you for your help. I apologize for having trouble with something that must be simple. I'm not sure how to insert/run the module in the query. I created a module and used your suggestion for the field name in the query, but I received the following error "undefined function 'WorkingDays' in expression."
I'd like to piggyback on this post if I could.
I'm trying to display the DateDiff result in a textbox on a report; my starting date is a field [SubmittedDate] and my ending date is Now() - I want it to calc the number of weekdays between the submitted date and whenever the report is ran.
I used the module posted (WorkingDays), changed its starting and ending dates to reflect my fields, created a textbox on my report with a control source of the WorkingDays function. When I run the report I get parameter boxes asking for "WorkingDay s", "SubmittedDate" , and "Now()" and then "Error" in the textbox on the completed report.
Advice?
Denburt 1,356
Recognized Expert Top Contributor
Thank you for your help. I apologize for having trouble with something that must be simple. I'm not sure how to insert/run the module in the query. I created a module and used your suggestion for the field name in the query, but I received the following error "undefined function 'WorkingDays' in expression."
Sorry it has been so long for me to get back with yall on this I have been out for a while.
Jen this may or may not be what you r looking for. I took a random table from a DB I have called Basis and it has a field name called Delivery_Month this is what the SQL would look like.
SELECT WorkingDays([Delivery_Month],Now()) AS NumberOfWeekDay s
FROM Basis;
My Basis table has a field in it called Delivery_Month and it is defined as a date field. This will give me the number of working days between the date in the Delivery_Month field and now or today. BTW you could also use date() since Now() provides the time as well and that really isn't needed.
Denburt 1,356
Recognized Expert Top Contributor Martin, I have no idea why you are having the problem you are having I have used the same table that I used in my last post added the field Delivery_Month to the report. Then in another Text Box I added the following and it seems to work just fine. =WorkingDays([Delivery_Month],Now()) of course again I would use date() just because it is a function designed for returning the date only. The function Now() also returns the time and may cause issues depending on the circumstances.
=WorkingDays([Delivery_Month],Date())
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: News Central |
last post by:
To all!
I use the DateDiff function using VB6 and get this error 'Wrong number of
argument or invalid property assignment' ... have anyone seen this problem?
thanks ....
|
by: Drago |
last post by:
Hi, I got the next question, I want to know the diference between two
dates
and thats is really easy, but my problem is get that diference in the
following format
ex. "the diference is= 0 year, 9 months, 11 days"
var1 = 04/04/1999
var2 = 01/11/2000
Response.Write("var1 to var2 is " & DateDiff("d", var1, var2) & " days
|
by: Lofty |
last post by:
Hi all.
I have to write an app that interacts with mySQL (I really must have done
some evil, evil stuff in a previous life to be landed with this!)
I need to work out the difference in days between values in the database and
the current date. "No problem," thought I , "I'll just use the SQL DATEDIFF
command." Heh! Well, the user interface I'm using didn't even recognise
DATEDIFF as being a function, so I decided to visit the mySQL...
|
by: intl04 |
last post by:
I'm trying to set up a query that will include a new field ('Days
until completion') whose value is derived from the DateDiff function.
I think I have the syntax correct but am not sure.
Days until completion: DateDiff("d",,)
is TODAY the appropriate syntax for today's date? Could the
function/expression even be set up that way, or do I need to do
something else to get 'days until completion'? (My Access manuals do
not mention a TODAY...
|
by: Paolo |
last post by:
I am having some problem with a Year Function.
I have form on which I have 4 field which indicate dates and an
additional form which sums those dates:
These are the fields:
YEARS
STARTINGDATE1
ENDINGDATE1
STARTINGDATE2
| |
by: PMBragg |
last post by:
ORINGINAL Post
>Thank you in advance. I'm trying to pull all inventory items from December
>of the previous year back to 4 years for my accountant. I know this can be
>done, but I'm drawing a blank. I've tried;
>
>DateDiff("y",-4,DateIn) and get errors
>
>Please any assistance would be greatly appreciated.
>
|
by: mcbill20 |
last post by:
Hello all. I have a really basic question that I hope someone has a
better answer for. I apologize in advance-- I know this is probably a
really basic question but I am used to Oracle rathern than Access.
I have a database where they customer wants to purge records from
certain tables after three years. When I was asked to make the changes
I originally thought this was an incredibly simple thing to do. I
looked at the function list and...
|
by: Adrian |
last post by:
I hit on this problem converting a VB.NET insurance application to C#.
Age next birthday calculated from date of birth is often needed in
insurance premium calculations.
Originally done using DateDiff in VB.NET which is only available in C#
if you don't mind linking in Microsoft.VisualBasic.dll to your C#
application.
I wanted to avoid this so set about a pure C# solution which uses a
combination of TimeSpan in whole days and the...
|
by: kevinjwilson |
last post by:
I am trying to get the date difference between two dates but I don't
want the function to include weekends in the calculation. Does anyone
have an idea on how to make this work?
|
by: muddasirmunir |
last post by:
i am using vb 6 , i had place two datepicker in form now i want to calcuate differcen of month in two date for this i used the function datediff
i had try it withh many syntax but getting error like
datediff(mm,date1,date2)
datediff(mmm,date1,date2)
datediff(month,date1,date2)
datediff("mm",date1,date2)
datediff("mmm",date1,date2)
datediff("month",date1,date2)
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
| |
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
| |
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |