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

Date Diff

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
Nov 15 '05 #1
5 5759
A wrote:
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)
Nov 15 '05 #2
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.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"A" <NO****@hotmail.com> wrote in message
news:%2***************@TK2MSFTNGP11.phx.gbl...
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

Nov 15 '05 #3
"A" <NO****@hotmail.com> wrote in
news:#4*************@TK2MSFTNGP11.phx.gbl:
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.
-------------
C.R. Timmons Consulting, Inc.
http://www.crtimmonsinc.com/
Nov 15 '05 #4

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.

Nov 15 '05 #5
[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)
Nov 15 '05 #6

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

Similar topics

6
by: Ralph Freshour | last post by:
What's a good way to calculate the number of days between two dates in the following format: 2003-07-15 2003-08-02 I've looked at the PHP date functions but I'm still a bit lost...
6
by: Pete | last post by:
Hi Guys I have a form which must calc the difference between 2 date fields and return the result in a third field. I have the following code but it does not seem to work. Can anyone tell this...
4
by: Richard Hollenbeck | last post by:
I'm trying to write some code that will convert any of the most popular standard date formats twice in to something like "dd Mmm yyyy" (i.e. 08 Jan 1908) and compare the first with the second and...
28
by: Steve | last post by:
Hi all How would I find out the average date when given a bunch of dates? For example, I want to find the average length in time from the following dates:...
3
by: Raghu Raman | last post by:
Hi I want to find the difference between 2 dates in terms of year.It is confusng in msdn.could u help me on that. for ex, int year=datediff("y",date1,date2)//of course it is in VB. ...
29
by: james | last post by:
I have a problem that at first glance seems not that hard to figure out. But, so far, the answer has escaped me. I have an old database file that has the date(s) stored in it as number of days. An...
2
by: yxq | last post by:
Hello, I found there are some date formats in the email header, for example: Fri, 23 Sep 2005 08:51:56 +0800 Sat, 17 Sep 2005 09:08:07 Wed Oct 19 13:40:23 2005 19 Oct 2005 13:40:23 +0000...
7
by: Gucci | last post by:
<?php /** * check ine year is a leap year, and return the month day array * * @param int $year **the year must bigger than zero** * @return array */ function is_leap_year($year){...
6
by: Jeremy Sanders | last post by:
Hi - I need to add support to a program for dates and times. The built-in Python library seems to be okay for many purposes, but what I would like would be Unix epoch style times (seconds relative...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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,...

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.