|
.net
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Q: DateTime DifferenceHello
I have TextBox1 this keeps date and time information and I need to compare this DateTime with the current DateTime and find difference in hour. How can I do this in VB.Net? Thanks, Use the DateTime.Subtract() method. When you subtract a DateTime from
another DateTime, it returns a TimeSpan, from which you can extract any portion. Example: DateTime dt = new DateTime(1, 4, 2005, 12, 12, 0); TimeSpan ts = DateTime.Now.Subtract(dt); int hours = ts.TotalHours; -- Show quoteHide quoteHTH, Kevin Spencer Microsoft MVP ..Net Developer You can lead a fish to a bicycle, but it takes a very long time, and the bicycle has to *want* to change. "JIM.H." <J***@discussions.microsoft.com> wrote in message news:22F17159-0525-4536-85A3-EAFBCC7C837D@microsoft.com... > Hello > I have TextBox1 this keeps date and time information and I need to compare > this DateTime with the current DateTime and find difference in hour. How > can > I do this in VB.Net? > > Thanks, >
Other interesting topics
possible java script question
FxCop App Security asp:Wizard inside of a asp:FormView breaks two-way databinding Problem with porting 1.1 code to 2.0 Web access failed - need help Can't get rid of the time part of a date Check textbox value... Syntax error about daAngio.Fill(dsAngio, "AngioInfo") Why aren't master pages part of themes? ASP Web site references to dlls |
|||||||||||||||||||||||