473,769 Members | 4,173 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 4841
On Sep 4, 2:30 am, ic...@scs.com.s g 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(txt Date1)
Date2=Cdate(txt Date2)
Years=DateDiff( "YYYY",Date1,Da te2)
Months=DateDiff ("M",Date1,Date 2) - (Years*12)
txtYIS=Format(Y ears) & " yrs " & format(Months) & " mth"

Sep 4 '07 #2
On Sep 4, 2:30 am, ic...@scs.com.s g 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********@Fort uneJames.com

Sep 6 '07 #3

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

Similar topics

5
3151
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 month and the next three months. I've been playing around with the date() function for a while now, and from that I can pull today's month and year, but I'm having problems with the transition from December to January. For instance, when i
13
3932
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 validated using the TEXTn_validate event but I would like to stop the user before it gets that far.
26
4415
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: starttime = Date.parse("Aug 10,2003, 07:07") sdt = new Date(starttime)
4
9341
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: (this needs to be automated to show years e.g. 46) I am trying to get the age to be automatically shown after a persons DoB (date of birth) is entered into the DoB field. I have tried using this formula in the Control Source of the Age field...
6
31822
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 elapsed time and somehow convert the days to years w/out using the VB DLL? Thanks.
8
2414
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 <conio.h> void main() { int month, day, year, c_year, c_month, t_days;
37
14962
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: case 8: case 11: case 14: case 17: return 1; default: return 0;
9
7903
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 between datetime instances returns a timedelta object that gives a number of days, but not an age So is there such a function somewhere ? If not, for what reason, since it's a rather usual task
15
6439
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 but that only gave me difference in hours and only if the times were on the same day (after wrapping with date() function). TIA
0
9423
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,...
0
10211
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, 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...
0
10045
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9863
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8872
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7409
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 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...
0
6673
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();...
0
5299
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...
3
2815
bsmnconsultancy
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...

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.