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

Home Posts Topics Members FAQ

How do I express a datediff in years & months? for example: 2 yrs 3 months

4 New Member
I am using a query:

LengthofEmployment2: IIf(IsNull([TerminationDate]),DateDiff("m",[HireDate],Now())/12,DateDiff("m",[HireDate],[TerminationDate])/12)
Jan 10 '11 #1
5 3217
Barb Crosby
4 New Member
LengthofEmployment: IIf(IsNull([TerminationDate]),DateDiff("m",[HireDate],Now())/12,DateDiff("m",[HireDate],[TerminationDate])/12)
Jan 10 '11 #2
Rabbit
12,516 Recognized Expert Moderator MVP
Integer division by 12 will give you years while mod 12 will give you months.
Jan 10 '11 #3
Barb Crosby
4 New Member
I'm sorry, but I'm not sure what you mean? integer division and mod division. Could you give me an example on how I would write the query?

The result of my query as I have it written gives me .67 years as opposed to 7 months. Is there a way to do this?
Jan 11 '11 #4
Rabbit
12,516 Recognized Expert Moderator MVP
Int(47 / 12) = 3
47 Mod 12 = 11
3 Years 11 Months.

Int(7 / 12) = 0
7 Mod 12 = 7
0 Years 7 Months.
Jan 11 '11 #5
Barb Crosby
4 New Member
Thank you. I will try that :)
Jan 13 '11 #6

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

Similar topics

23
by: Alberto | last post by:
An OUTSTANDING example of a rebuttal. Worth a glance. Rather long, OBVIOUSLY feel fee to dismiss it entirely if not interested. But this habit of the rebuttals must go to a stop (forgive odd...
0
by: Kevin | last post by:
Group By - Client Sum - Past:IIF(DateDiff("d",,Date())>30,,0) Sum - Current:IIF(DateDiff("d",,Date())<31,,0) Works for positive numbers, but if InvoiceNetTotal = ($4.00) and InvoiceNetTotal =...
6
by: carl.barrett | last post by:
Hi, I have a continuous form based on a query ( I will also be creating a report based on the same query). There are 2 fields: Date Obtained and Date Of Expiry I want a further 3 columns...
14
by: jpr | last post by:
Friends, I have a form with four fields, date1, date2, date3 and date4. All these have all a mm/dd/yyyy format and have their source to a table. I need to add an unbound control (I will name...
2
by: arnuld | last post by:
on page 29, section 1.9 Character Arrays, i see an example: /* getline: read a line into s, return length */ int getline(char s,int lim) { int c, i; for (i=0; i < lim-1 &&...
7
by: Chris Hills | last post by:
At last the MISRA-C:2004 TC and exemplar suite have been released. See http://www.misra-c2.com/forum/index.php You have to register to access the resources section where both are on free...
2
by: ichew | last post by:
I have two dates - Date Joined and Actual Last Day. How do I find the YIS in for format of Years and Month from these two dates. Eg, Date Joined: 28/06/1971 and Actual Last Day: 24/01/2007, then...
15
karthickkuchanur
by: karthickkuchanur | last post by:
Hai sir, i assigned to calculate the age from current date ,i have the date of birth of employee from that i have to calculate the age dynamically, i refer to google it was confusing...
3
by: Imaginativeone | last post by:
XML <nodeAA>AA</nodeAA> <nodeBB>BB</nodeBB> <nodeCC> <From>12/05</From> <To>11/06</To> <Months>12</Months> <Amount>10.00</Amount> ...
4
by: ronakinuk | last post by:
Hi Can someone , guide me how can i make a database in oracle with front end on the website (i guest html or asp) please I have oracle express edition and microsoft visual studio. can i make such...
0
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...
0
Oralloy
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,...
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...
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,...
1
isladogs
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...
0
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...
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 ...
1
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.