473,436 Members | 1,506 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,436 software developers and data experts.

Calculate Year In Service (YIS) in the format of Years and month

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 the YIS
should shows: 35 yrs 6 mth.

Sep 4 '07 #1
2 4812
On Sep 4, 2:30 am, ic...@scs.com.sg wrote:
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 the YIS
should shows: 35 yrs 6 mth.
Use DateDiff( ) to get the months and years. For example, if you had
a textbox named txtDate1 and a texbox named txtDate2, and a textbox
named txtYIS, then you could put the following code in the click event
of a command button, or in the AfterUpdate event of some control:

Dim Date1 as Date
Dim Date2 as Date
Dim Years as Integer
Dim Months as Integer

Date1=Cdate(txtDate1)
Date2=Cdate(txtDate2)
Years=DateDiff("YYYY",Date1,Date2)
Months=DateDiff("M",Date1,Date2) - (Years*12)
txtYIS=Format(Years) & " yrs " & format(Months) & " mth"

Sep 4 '07 #2
On Sep 4, 2:30 am, ic...@scs.com.sg wrote:
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 the YIS
should shows: 35 yrs 6 mth.
In:

http://groups.google.com/group/micro...03152fa335dbe9

I posted a query for elapsed time in years, months and days. It
should work on non-U.S. dates. It seems to give results that match
what I expect. I have not studied OldPro's solution.

James A. Fortune
CD********@FortuneJames.com

Sep 6 '07 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Tencip | last post by:
Hi everyone, I'm trying to build a simple script that does the following. It should find today's month and year, and then go into a DB query string and look for all records that are from this...
13
by: David Gray | last post by:
Greetings all, Quick newbie type question: I would like to be able to trap non-numerical data entered into a textbox via CTRL+C and/or Shift+Insert. I realise that this data can be...
26
by: Frank | last post by:
For my website i would like to display the age of my son in years, months, days and hours. For now i manage to get a result for totals. Like the total number of days. This is the beginning: ...
4
by: Jan Szymczuk | last post by:
I'm creating an MS Access 2000 database where I have a number of people entered using simple basic fields, Surname: SMITH Forenames: John DoB: 09/09/1958 Age:...
6
by: charliewest | last post by:
Can someone pls point me to or recommend the easiest way to calculate someone´s age using the TimeSpan object, in .NET CF? Isn´t there a simple way to use the TimeSpan object to calculate the...
8
by: amackeyb | last post by:
I need to do a program that calculate the days from a date whatever since 20XX to January 1st. 2000. How can I do that?? I have this, is it correct??? # include <iostream.h> # include...
37
by: mazwolfe | last post by:
I'm new here, so excuse me if my style is incorrect. Can anyone come up with a better method for this calculation? Code: int is_leap(int year) { switch (year % 19) { case 0: case 3: case 6:...
9
by: Pierre Quentel | last post by:
Hi all, I have searched in the standard distribution if there was a function to return the difference between 2 dates expressed like an age : number of years, of months and days. The difference...
15
by: student4lifer | last post by:
Hello, I have 2 time fields dynamically generated in format "m/d/y H:m". Could someone show me a good function to calculate the time interval difference in minutes? I played with strtotime() but...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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
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
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: 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...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

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.