473,467 Members | 1,603 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Dates in reports

rcollins
234 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.
Jul 12 '07 #1
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
Jul 12 '07 #2
missinglinq
3,532 Recognized Expert Specialist
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:

Expand|Select|Wrap|Line Numbers
  1. Function D2YMD(No As Integer) As Variant
  2. Dim Y As Long
  3. Dim M As Long
  4. Dim D As Long
  5.  
  6. Y = Int(No / 365)
  7. M = Int((No - (Int(No / 365) * 365)) / 30)
  8. D = No - ((Y * 365) + (M * 30))
  9.  
  10. D2YMD = Y & " years " & M & " months " & D & " days"
  11. End Function
  12.  
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)>
Jul 12 '07 #3
rcollins
234 New Member
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
Jul 13 '07 #4
rcollins
234 New Member
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()?
Jul 13 '07 #5
rcollins
234 New Member
[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.
Jul 13 '07 #6
missinglinq
3,532 Recognized Expert Specialist
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)>
Jul 13 '07 #7
rcollins
234 New Member
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?
Jul 19 '07 #8

Sign in to post your reply or Sign up for a free account.

Similar topics

6
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...
1
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...
3
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...
8
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...
1
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...
0
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...
7
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....
6
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...
4
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...
9
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...
1
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...
0
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...
0
marktang
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,...
0
jinu1996
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...
1
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...
0
tracyyun
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...
0
agi2029
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,...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
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 ...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.