PC Review


Reply
Thread Tools Rate Thread

datetime differences

 
 
SenthilVel
Guest
Posts: n/a
 
      7th Jan 2005
HI

how to get the differences in 2 given dates??

supposse if i ahve 2 dates , DATEa, and current datetime.

how can i find if the DATEa is less then 3 hrs from the current datetime ???


,,,,
Senthil


 
Reply With Quote
 
 
 
 
Tom Shelton
Guest
Posts: n/a
 
      7th Jan 2005
On 2005-01-07, SenthilVel <(E-Mail Removed)> wrote:
> HI
>
> how to get the differences in 2 given dates??
>
> supposse if i ahve 2 dates , DATEa, and current datetime.
>
> how can i find if the DATEa is less then 3 hrs from the current datetime ???
>
>
> ,,,,
> Senthil
>
>


TimeSpan diff = DateTime.Now.Subtract (dateA);
if (diff.TotalHours < 3)
{
// do cool stuff
}

--
Tom Shelton [MVP]
 
Reply With Quote
 
vooose
Guest
Posts: n/a
 
      7th Jan 2005
Look at the TimeSpan class.

Do

TimeSpan t1 = date1 - date2;
t1.TotalHours

Wal
http://www.vooose.com
--

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
 
Reply With Quote
 
Maqsood Ahmed
Guest
Posts: n/a
 
      7th Jan 2005
Hello,
Please see the following code snippet for the task you want to do.

//Assign dateA
TimeSpan timeSpan = DateTime.Now.Subtract(dateA);

Use timeSpan.TotalHours to get total hours

Maqsood Ahmed [MCP,C#]
Kolachi Advanced Technologies
http://www.kolachi.net

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
 
Reply With Quote
 
Mike Kitchen
Guest
Posts: n/a
 
      7th Jan 2005
Hi Senthil

This has been addressed several times here.

I have compiled the common answer in my snippets page found at

http://www.publicjoe.f9.co.uk/csharp/snip/snip005.html

Hope this helps

Publicjoe
C# Tutorial at http://www.publicjoe.f9.co.uk/csharp/tut.html
C# Snippets at http://www.publicjoe.f9.co.uk/csharp/snip/snippets.html
C# Ebook at http://www.publicjoe.f9.co.uk/csharp/samples/ebook.html
VB Ebook at http://www.publicjoe.f9.co.uk/vbnet/samples/ebook.html


"SenthilVel" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> HI
>
> how to get the differences in 2 given dates??
>
> supposse if i ahve 2 dates , DATEa, and current datetime.
>
> how can i find if the DATEa is less then 3 hrs from the current datetime

???
>
>
> ,,,,
> Senthil
>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Compare and highlight differences in 2 worksheets in same workbookand list differences in 3rd worksheet Joshua Houck Microsoft Excel Programming 21 19th Aug 2011 12:21 PM
Millisecond values missing when inserting datetime into datetime column of sql Server Manikandan Microsoft C# .NET 4 18th Jul 2007 08:59 PM
How can I save a DateTime from my C# program into a SQL Server (datetime) database column. Steve Kershaw Microsoft ASP .NET 5 29th Aug 2006 03:10 AM
DateTime conversion to its sqlServer datetime float representation. A.Neves Microsoft C# .NET 1 20th Apr 2006 01:01 PM
Re: DateTime & Regional Setting differences Ron McNulty Microsoft Dot NET Framework 0 4th Aug 2003 11:36 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 02:56 AM.