Date Diff

  • Thread starter Thread starter A
  • Start date Start date
A

A

Hi Group,

Coming from a VB background I am looking for the quickest path to do a date
diff in C#. I see that C# has no date diff function so this must be more
obvious than it looks.

Thanks
 
A said:
Hi Group,

Coming from a VB background I am looking for the quickest path to do
a date diff in C#. I see that C# has no date diff function so this
must be more obvious than it looks.

What's the difference between a "date diff" and thisDate - thatDate?

--
There are 10 kinds of people. Those who understand binary and those who
don't.

http://code.acadx.com
(Pull the pin to reply)
 
A,

It is =)

If you have two variables of type DateTime, you can do this:

// The first date.
DateTime pdatStart = DateTime.Now;

// Wait for two seconds.
Thread.Sleep(2000);

// Get the time.
DateTime pdatEnd = DateTime.Now;

// Get the difference.
TimeSpan pobjDifference = pdatEnd - pdatStart;

The TimeSpan class is used to handle differences in datetime values.

Hope this helps.
 
Hi Group,

Coming from a VB background I am looking for the quickest path
to do a date diff in C#. I see that C# has no date diff
function so this must be more obvious than it looks.

Look in the help file for "DateTime Structure" and "TimeSpan
Structure".

Chris.
 
Hi

Based on my understanding, you want to do "date diff" in C#.
Actully, all .Net languages use the .Net class library to do operations.
So you can refer to .Net structure DateTime and TimeSpan. It is not the
feature of C#, but included in the .Net class library which can also be
used by VB.net etc.

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
 
[OT]

Would you mind having a look at my pose "UCOMIMoniker.BindToObject"? I'm
desperately seeking a solution and no one seems to know just how this
method works.

--
There are 10 kinds of people. Those who understand binary and those who
don't.

http://code.acadx.com
(Pull the pin to reply)
 
Back
Top