at I have is a start and end date in my report. I need to put the value of days that I got, 619.19, into how many years, months and days. Please advise.
7 1533 hyperpau 184
Recognized Expert New Member
at I have is a start and end date in my report. I need to put the value of days that I got, 619.19, into how many years, months and days. Please advise.
use the DateDiff functions
example:
for days
=DateDiff("d","StartDate","EndDate")
form months
=DateDiff("m","StartDate","EndDate")
for years
=DateDiff("y","StartDate","EndDate")
I know not how to do all of the three in one control only
The problem, of course, is that all years don't have 365 days in them, and months can have 28, 29, 30 or 31 days! So any conversion from days to years/months/days is going to be slightly inaccurate. With that in mind, from the Objects Dialog box goto Modules. Click on New and paste in this code: - Function D2YMD(No As Integer) As Variant
-
Dim Y As Long
-
Dim M As Long
-
Dim D As Long
-
-
Y = Int(No / 365)
-
M = Int((No - (Int(No / 365) * 365)) / 30)
-
D = No - ((Y * 365) + (M * 30))
-
-
D2YMD = Y & " years " & M & " months " & D & " days"
-
End Function
-
When Access asks if you want to save the module (it'll probably be called Module1 at this point) answer Yes and name it DaysConversions.
Then in your report place an unbound textbox and give as it's Control Source =D2YMD(DateDiff("d","StartDate","EndDate"))
Good Luck!
Linq ;0)>
Can I just change this =D2YMD(DateDiff("d","StartDate","EndDate"))
which works fine
to this to get an average? =Avg(D2YMD(DateDiff("d","StartDate","EndDate")))
It gives me a data type mismatch
When th formula figures start to end date, I get an error. Of course, there are people who have not finished their jobs. How can I set a null end time to Date()?
[Ok, so tI got it working. to use Nz([EndDate],Date()) to get the current date in the field. That workedeg good. The only thing I didn't quite understand, it hte code that you gave me, I put in a seperate text box the refered to it from the one I wanted the avg. All worked, though. Thank you for your help.
D2YMD(DateDiff("d","StartDate","EndDate") returns a string with letters and numbers in it so you can't "average" a string with mixed characters and hence the mismatch. Glad you got it working for you!
Linq ;0)>
Now I need to figure the lenght of time that it took the clients to find a job. Right now, I have it set to average from the date of registration to the start date, the problem is that it takes all of there jobs, I want just the first one.
Also, with average hours worked and average rate of pay, I only want this to come from the current job. How can I do this using the null value for the end date?
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Kris M |
last post by:
How do i handle a null value for a date variable type. I am retrieving date
data from an access database and storing the records in an array for
processing. The array field has a date type and the...
|
by: Michael DeLawter |
last post by:
Using Access 2002.
I have a chart in a report that is currently based on a query in which
the user enters the start and end date for the chart to display. Both
the start and end dates have been...
|
by: SJH |
last post by:
I currently have reports (mostly graphs) that utilize dates entered into a
form. The dates are pretty baisc from the standpoint of the start and end
of the current fiscal year, the start and end...
|
by: Donna Sabol |
last post by:
First, I should start by saying I am creating a database to be used by
some very impatient, non-computer literate people. It needs to be
seameless in it's operation from their point of view. I...
|
by: Don Sealer |
last post by:
I have a report that includes 5 different subreports. I'd like to be
able to open this report using a date function (Start Date and End Date).
I'd like all five subreports to show the data from...
|
by: Don Sealer |
last post by:
I have a report that includes 5 different subreports. I'd like to be
able to open this report using a date function (Start Date and End Date).
I'd like all five subreports to show the data from...
|
by: evilcowstare via AccessMonster.com |
last post by:
Hi, I have searched the forum for answers on this and to be honest as a
novice I find it a bit confusing so apologies if it is simple.
There are some searches that I want to apply to my database....
|
by: tshad |
last post by:
Apparently, I can't do:
Dim da2 As New OleDb.OleDbDataAdapter("Select PR,
Convert(varchar,getchar(),1),F1, F2, F5, Sum(F4) from temp
....
I am getting this error.
'undefined function...
|
by: jdph40 |
last post by:
I enter data into a database that resides on our network. Other
employees can print reports from the database, but they have no way of
telling if I've entered all the data. For instance, on...
|
by: sparks |
last post by:
Right now I had to build a report that allowed the people to check for
gross outliers in their data input.
short I am looking at 2.5* std dev + -
anyway I used 2 dummy variables in the query the...
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
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,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
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...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
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 ...
| |