473,788 Members | 2,725 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Trying to get a Date Breakdown

I am trying to get a overall difference on two dates,

I can get the difference in Years, Months, Weeks, Days, Hours, Minutes,
Seconds, no problems...

What I cannot seem to figure out is how to get:

2 Years, 3 Months, 1 Week, 3 Days, 14 Hours, 21 Minutes, 33 Seconds.

The hardest part of that, the part I cannot figure out, is the Month
section... all the others are static, defined length components, but Months
change, are all different...

Help! anyone know how you do this? I am stuck...

Thanks So Much for your Help!

Atley
Nov 20 '05 #1
16 1640
what about getting the difference incerementally.

1st you get the difference in Year and substract it
2nd you get the difference in month and substract it
3rd .... (etc ...)

"Atley" <at*****@hotmai l.com> wrote in message
news:OI******** ******@TK2MSFTN GP12.phx.gbl...
I am trying to get a overall difference on two dates,

I can get the difference in Years, Months, Weeks, Days, Hours, Minutes,
Seconds, no problems...

What I cannot seem to figure out is how to get:

2 Years, 3 Months, 1 Week, 3 Days, 14 Hours, 21 Minutes, 33 Seconds.

The hardest part of that, the part I cannot figure out, is the Month
section... all the others are static, defined length components, but Months change, are all different...

Help! anyone know how you do this? I am stuck...

Thanks So Much for your Help!

Atley

Nov 20 '05 #2
Yeah, I thought of that, but how do I decide what to delete from the total,
based on how many months?

"Lloyd Dupont" <net.galador@ld > wrote in message
news:eM******** *****@TK2MSFTNG P12.phx.gbl...
what about getting the difference incerementally.

1st you get the difference in Year and substract it
2nd you get the difference in month and substract it
3rd .... (etc ...)

"Atley" <at*****@hotmai l.com> wrote in message
news:OI******** ******@TK2MSFTN GP12.phx.gbl...
I am trying to get a overall difference on two dates,

I can get the difference in Years, Months, Weeks, Days, Hours, Minutes,
Seconds, no problems...

What I cannot seem to figure out is how to get:

2 Years, 3 Months, 1 Week, 3 Days, 14 Hours, 21 Minutes, 33 Seconds.

The hardest part of that, the part I cannot figure out, is the Month
section... all the others are static, defined length components, but

Months
change, are all different...

Help! anyone know how you do this? I am stuck...

Thanks So Much for your Help!

Atley


Nov 20 '05 #3
I don't get you.

wether month have different lenght or you modify start or end date, the
result should be the same (I guess)

like
2 Feb (2) 2002 - 1st Jan (1) 2001
= 1Y + (2 Feb 2001 - 1st Jan 2001) OR 1 year + (2 Feb 2002 - 1st Jan 2002)
= 1Y + 1M + (2 Jan 2001 - 1st Jan 2001) OR 1Y+1M+(2Feb2002-1stFeb2002)
= 1Y + 1M + 1D OR 1Y + 1M + 1D

isn't it ?

"Atley" <at*****@hotmai l.com> wrote in message
news:up******** ******@TK2MSFTN GP10.phx.gbl...
Yeah, I thought of that, but how do I decide what to delete from the total, based on how many months?

"Lloyd Dupont" <net.galador@ld > wrote in message
news:eM******** *****@TK2MSFTNG P12.phx.gbl...
what about getting the difference incerementally.

1st you get the difference in Year and substract it
2nd you get the difference in month and substract it
3rd .... (etc ...)

"Atley" <at*****@hotmai l.com> wrote in message
news:OI******** ******@TK2MSFTN GP12.phx.gbl...
I am trying to get a overall difference on two dates,

I can get the difference in Years, Months, Weeks, Days, Hours, Minutes, Seconds, no problems...

What I cannot seem to figure out is how to get:

2 Years, 3 Months, 1 Week, 3 Days, 14 Hours, 21 Minutes, 33 Seconds.

The hardest part of that, the part I cannot figure out, is the Month
section... all the others are static, defined length components, but

Months
change, are all different...

Help! anyone know how you do this? I am stuck...

Thanks So Much for your Help!

Atley



Nov 20 '05 #4
Yea, but how would you do that in code, that will work for any dates put in?
What I am saying is I can't find the constructs or methods that will do this
effectively.


"Lloyd Dupont" <net.galador@ld > wrote in message
news:%2******** ********@TK2MSF TNGP10.phx.gbl. ..
I don't get you.

wether month have different lenght or you modify start or end date, the
result should be the same (I guess)

like
2 Feb (2) 2002 - 1st Jan (1) 2001
= 1Y + (2 Feb 2001 - 1st Jan 2001) OR 1 year + (2 Feb 2002 - 1st Jan 2002)
= 1Y + 1M + (2 Jan 2001 - 1st Jan 2001) OR 1Y+1M+(2Feb2002-1stFeb2002)
= 1Y + 1M + 1D OR 1Y + 1M + 1D

isn't it ?

"Atley" <at*****@hotmai l.com> wrote in message
news:up******** ******@TK2MSFTN GP10.phx.gbl...
Yeah, I thought of that, but how do I decide what to delete from the

total,
based on how many months?

"Lloyd Dupont" <net.galador@ld > wrote in message
news:eM******** *****@TK2MSFTNG P12.phx.gbl...
what about getting the difference incerementally.

1st you get the difference in Year and substract it
2nd you get the difference in month and substract it
3rd .... (etc ...)

"Atley" <at*****@hotmai l.com> wrote in message
news:OI******** ******@TK2MSFTN GP12.phx.gbl...
> I am trying to get a overall difference on two dates,
>
> I can get the difference in Years, Months, Weeks, Days, Hours, Minutes, > Seconds, no problems...
>
> What I cannot seem to figure out is how to get:
>
> 2 Years, 3 Months, 1 Week, 3 Days, 14 Hours, 21 Minutes, 33 Seconds.
>
> The hardest part of that, the part I cannot figure out, is the Month
> section... all the others are static, defined length components, but
Months
> change, are all different...
>
> Help! anyone know how you do this? I am stuck...
>
> Thanks So Much for your Help!
>
> Atley
>
>



Nov 20 '05 #5
I'm not sure I understand exactly what the problem is, but isn't it just
something as simple as:

Dim d1 As New Date(2006, 10, 20)
Dim d2 As New Date(2003, 1, 9)
Dim yDiff As Integer = d1.Year - d2.Year
Dim mDiff As Integer = d1.Month - d2.Month
Dim dDiff As Integer = d1.Day - d2.Day

Or are you asking for something more complicated?

Steven

"Atley" <at*****@hotmai l.com> wrote in message
news:%2******** ********@TK2MSF TNGP10.phx.gbl. ..
Yea, but how would you do that in code, that will work for any dates put in? What I am saying is I can't find the constructs or methods that will do this effectively.


"Lloyd Dupont" <net.galador@ld > wrote in message
news:%2******** ********@TK2MSF TNGP10.phx.gbl. ..
I don't get you.

wether month have different lenght or you modify start or end date, the
result should be the same (I guess)

like
2 Feb (2) 2002 - 1st Jan (1) 2001
= 1Y + (2 Feb 2001 - 1st Jan 2001) OR 1 year + (2 Feb 2002 - 1st Jan 2002) = 1Y + 1M + (2 Jan 2001 - 1st Jan 2001) OR 1Y+1M+(2Feb2002-1stFeb2002)
= 1Y + 1M + 1D OR 1Y + 1M + 1D

isn't it ?

"Atley" <at*****@hotmai l.com> wrote in message
news:up******** ******@TK2MSFTN GP10.phx.gbl...
Yeah, I thought of that, but how do I decide what to delete from the

total,
based on how many months?

"Lloyd Dupont" <net.galador@ld > wrote in message
news:eM******** *****@TK2MSFTNG P12.phx.gbl...
> what about getting the difference incerementally.
>
> 1st you get the difference in Year and substract it
> 2nd you get the difference in month and substract it
> 3rd .... (etc ...)
>
> "Atley" <at*****@hotmai l.com> wrote in message
> news:OI******** ******@TK2MSFTN GP12.phx.gbl...
> > I am trying to get a overall difference on two dates,
> >
> > I can get the difference in Years, Months, Weeks, Days, Hours,

Minutes,
> > Seconds, no problems...
> >
> > What I cannot seem to figure out is how to get:
> >
> > 2 Years, 3 Months, 1 Week, 3 Days, 14 Hours, 21 Minutes, 33 Seconds. > >
> > The hardest part of that, the part I cannot figure out, is the Month > > section... all the others are static, defined length components, but > Months
> > change, are all different...
> >
> > Help! anyone know how you do this? I am stuck...
> >
> > Thanks So Much for your Help!
> >
> > Atley
> >
> >
>
>



Nov 20 '05 #6
Cor
Hi Atley,

Did you know that Date is the topic of this week on MSDN

http://msdn.microsoft.com/netframewo...tetimecode.asp

Cor
Nov 20 '05 #7
something like this?

dim date1 as datetime
dim date2 as datetime

dim ticks1 as long = date1.ticks
dim ticks2 as long = date2.ticks

dim difference as new timespan(math.a bs(ticks1 - ticks2))
Dominique


"Atley" <at*****@hotmai l.com> wrote in message
news:OI******** ******@TK2MSFTN GP12.phx.gbl...
I am trying to get a overall difference on two dates,

I can get the difference in Years, Months, Weeks, Days, Hours, Minutes,
Seconds, no problems...

What I cannot seem to figure out is how to get:

2 Years, 3 Months, 1 Week, 3 Days, 14 Hours, 21 Minutes, 33 Seconds.

The hardest part of that, the part I cannot figure out, is the Month
section... all the others are static, defined length components, but Months change, are all different...

Help! anyone know how you do this? I am stuck...

Thanks So Much for your Help!

Atley

Nov 20 '05 #8
Thanks, but i can get the DateDiff several different ways, the problem is
with the breakdown into how much time is left as a rundown ie 1 year, 2
months, 1 week, 3 days, 6 hours, 23 minutes, 41 seconds...

"Dominique Vandensteen" <domi.vds_inser t@tralala_tenfo rce.com> wrote in
message news:OK******** *****@TK2MSFTNG P11.phx.gbl...
something like this?

dim date1 as datetime
dim date2 as datetime

dim ticks1 as long = date1.ticks
dim ticks2 as long = date2.ticks

dim difference as new timespan(math.a bs(ticks1 - ticks2))
Dominique


"Atley" <at*****@hotmai l.com> wrote in message
news:OI******** ******@TK2MSFTN GP12.phx.gbl...
I am trying to get a overall difference on two dates,

I can get the difference in Years, Months, Weeks, Days, Hours, Minutes,
Seconds, no problems...

What I cannot seem to figure out is how to get:

2 Years, 3 Months, 1 Week, 3 Days, 14 Hours, 21 Minutes, 33 Seconds.

The hardest part of that, the part I cannot figure out, is the Month
section... all the others are static, defined length components, but

Months
change, are all different...

Help! anyone know how you do this? I am stuck...

Thanks So Much for your Help!

Atley


Nov 20 '05 #9
Cor
Hi Atley,

Did you look at the
timespan.ticksp ersecond
timespan.ticksp eryear
timespan.ticksp erhour
etc.

I hope this helps,

Cor
Nov 20 '05 #10

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

Similar topics

10
1439
by: Sean Ross | last post by:
Here's a breakdown of most of the syntax discussed re: PEP318 using an example from python-dev. There are probably several more (I've added ). The example applies both function decoration and annotation. # .. , competing ways to say the same thing # def foo(self) : "doc string"
0
1386
by: Marco Alting | last post by:
Hi I have a created a cost reporting system which shows a level-breakdown report. There are three levels in the report the lowest level holds the cost items that are entered by the user these records also have an Entry Date. The level above that is a Sum of the lowest level and the top level is the Sum of the second level. I created the solution using three queries in Access. I then use the queries in ASP to generate the report. But now...
0
2148
by: BuddyWork | last post by:
Hello, I want to know if there any good tools out there which will show me a breakdown of the memory allocation in Gen 2 heap, basically a breakdown by object is what I'm looking for. The reason for this is that I eventually get the OutOfMemory exception. I can see the GEN2, GEN1, GEN0 GC kicking in but when run a pariticular code approx 2333
5
2284
by: TN Bella | last post by:
Trying to check if an entry for an date is < 3 years to current date or > 30 days from current date. How can I do this in asp.net....? Do I need to use the customvalidation. Can anyone give me an example? Thanks in advance for the help *** Sent via Devdex http://www.devdex.com *** Don't just participate in USENET...get rewarded for it!
25
4074
by: Neo Geshel | last post by:
This works: <form> <asp:TextBox id="name" /> <%= name.ClientID %> </form> But this DOES NOT work: <form>
5
3647
by: snicks | last post by:
I'm trying to exec a program external to my ASP.NET app using the following code. The external app is a VB.NET application. Dim sPPTOut As String sPPTOut = MDEPDirStr + sID + ".ppt" Dim p As New System.Diagnostics.Process 'p.Start(MDEPDirStr & "macrun.exe", sPPTOut) p.Start("C:\WINDOWS\SYSTEM32\CALC.EXE") 'p.Start("C:\WINDOWS\SYSTEM32\macrun.exe", sPPTOut)
9
7450
by: flanagak | last post by:
All, I was wondering if someone could point me in the right direction to decode the following information. I am working on a tool writen in C and one of the items in the file I am decoding is a timestamp in this format. I had started looking at a bitfield structure, but I am wondering if there is a better / more portable solution. Hex Value in the file: 9D AF 79 C0 Binary breakdown: 1001(9) 1101(D) 1010(A) 1111(F) 0111(7) 1001(9)...
3
4602
by: Daron | last post by:
Is it possible to use SQL to take a field, and break it down by denominations? I would like to take a field, and then break this out into the number of bills($100's, $50's, etc) I would need: $469.32 = 4x$100 1x$50 1x$10 1x$5
5
3426
by: Pauley | last post by:
Hello, Please keep in mind when you read this post that I am a total noob when it comes to coding. Coding in ASP On MS Server SQL Database/Table I know this topic has been covered many times and many ways. In fact I've tried to use one version or another of 20 examples with no success. All I am trying to do is determine the timespan between the date a sql record was submitted and the current date.
0
9656
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10366
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...
1
10110
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8993
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
7517
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
5399
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...
1
4070
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 we have to send another system
2
3674
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2894
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.