473,408 Members | 1,772 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,408 software developers and data experts.

years,months,days

Exists a function that determined between two dates the years,months and
days?

Thanks a lot.
Jun 3 '06 #1
8 1750
dim x as date = someDate.subtract(someOtherDate)

Then format x as desired.

"Jose" <jo********@unica.com> wrote in message
news:ui**************@TK2MSFTNGP04.phx.gbl...
Exists a function that determined between two dates the years,months and
days?

Thanks a lot.

Jun 3 '06 #2
Scott M. wrote:
dim x as date = someDate.subtract(someOtherDate)


The Subtract method on the DateTime structure, when passed another
DateTime, returns a Timespan object and not a DateTime object.

Dim ts As TimeSpan = someDate.Subtract(someOtherDate)

Then you can get the years, months, and days properties from the
TimeSpan.

Jun 5 '06 #3
Chris Dunaway wrote:
Scott M. wrote:
dim x as date = someDate.subtract(someOtherDate)


The Subtract method on the DateTime structure, when passed another
DateTime, returns a Timespan object and not a DateTime object.

Dim ts As TimeSpan = someDate.Subtract(someOtherDate)

Then you can get the years, months, and days properties from the
TimeSpan.


Actually, you can only get the value as days.

As the timespan doesn't contain a starting and ending time, there is no
way to determine the exact length in months and years.
Jun 5 '06 #4
or you could use a real function like DateDiff right?

who the hell changes a function like DateDiff??

-Aaron
Göran Andersson wrote:
Chris Dunaway wrote:
Scott M. wrote:
dim x as date = someDate.subtract(someOtherDate)


The Subtract method on the DateTime structure, when passed another
DateTime, returns a Timespan object and not a DateTime object.

Dim ts As TimeSpan = someDate.Subtract(someOtherDate)

Then you can get the years, months, and days properties from the
TimeSpan.


Actually, you can only get the value as days.

As the timespan doesn't contain a starting and ending time, there is no
way to determine the exact length in months and years.


Jun 5 '06 #5
Göran Andersson wrote:

Actually, you can only get the value as days.


I stand corrected. But when you subtract a date from another date, it
returns a Timespan and not a date.

Jun 6 '06 #6
Jose,

In my idea does this never work as measuring system. Somehow I thought it is
not possible with the Gregorian Calender, every month can have a different
length you know, not to talk about leap years. Therefore it is not such a
good measuring system.

Therefore
Date - Date represented as year, months, will will give a total other
result in by instance days as you use another startdate and add your
measured result.

(Years, weeks, days) or (years, days) will do a better job.
Although the leap year problem sustains..

That is the reason that some people want to use this kind of calendars.

http://en.wikipedia.org/wiki/Positivist_Calendar

But just my thought.

Cor
Jun 6 '06 #7
Chris Dunaway wrote:
Göran Andersson wrote:
Actually, you can only get the value as days.


I stand corrected. But when you subtract a date from another date, it
returns a Timespan and not a date.


Yes. If you read my next sentence you see that I am referring to the
TimeSpan structure. That implies that I concur with your observation. :)
Jun 6 '06 #8
Göran Andersson wrote:
Yes. If you read my next sentence you see that I am referring to the
TimeSpan structure. That implies that I concur with your observation. :)


My mistake, I was actually replying to Scott M.'s message.

Jun 7 '06 #9

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

Similar topics

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...
5
by: Juan | last post by:
Hi everyone, is there a function that calculates the exact amount of Years, Months, and Days between two days? TimeDiff is not good enough, since it calculates, for example: Date 1: Dec....
1
by: ann | last post by:
is there someway to disable the Other Months day(the previous and next months days) s from appearing? If so, can you let me know how? Thanks so much for your help!
3
by: Trevor | last post by:
This is driving us mad - please help! Back in 2003, I coded a Windows Service in VB.NET for framework v1.1.4322. I deployed it in Nov. 2003, and it worked fine until the end of May 2005, when it...
37
by: Gregc. | last post by:
G'day I'm trying to work out the number of years since 1970, here is my code: include <stdio.h> #include <time.h> const int SEC_IN_MIN = 60; const int SEC_IN_HOUR = SEC_IN_MIN * 60;
5
by: mukesh | last post by:
Dear freinds, I need date difference in terms of years/months/days i.e. i want to create a calculated field to show the age of person in year months and days. The DateDiff() expression of MS...
2
by: vsankar9 | last post by:
End date - 31-DEC-2007 Termination as of date - 15-MAR-2007 Rate - 1000 (monthly rate ) Termination value =( 9 Months * 1000 )+ (16 days * 1000 / 30) = 9000 + 533.33 = 9533.33
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...
2
by: johanneguaybenoit | last post by:
Hi I would like to know how to create a function or module to calculate the age of a person in years months days. and hours if feasable But I really nead to know in years months days. I...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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
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...

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.