Ariez Posted April 10, 2003 Posted April 10, 2003 Dim myTime As DateTime myTime = DateTimePicker1.Text this gives me a big number when i should have a few secs TextBox1.Text = DateDiff(DateInterval.Second, Now(), DateAdd(DateInterval.Second, CType(myTime.ToOADate(), Double), System.DateTime.Today)) And this gives me a big number too TextBox1.Text = DateDiff(DateInterval.Second, Now(), myTime) I need to get the diff in secs between a time #7:35:04 PM# kept in myTime and Now()... Anyone could help on this? Quote Auto-suggestion: "I have a life" Uncontroled thinking: "So what the.."
Leaders quwiltw Posted April 10, 2003 Leaders Posted April 10, 2003 You should probably check out the TimeSpan class. Quote --tim
Ariez Posted April 10, 2003 Author Posted April 10, 2003 (edited) this does it.. TextBox1.Text = DateDiff(DateInterval.Second, Now(), DateAdd(DateInterval.Second, (Mytime.Hour * 60 * 60) + (Mytime.Minute * 60) + (Mytime.Second), System.DateTime.Today)) is there a more elegant way to convert a time #hh:mm:ss# into seconds? Edited April 10, 2003 by Ariez Quote Auto-suggestion: "I have a life" Uncontroled thinking: "So what the.."
Ariez Posted April 10, 2003 Author Posted April 10, 2003 (edited) this does it too and looks good... SecDiff = DateDiff(DateInterval.Second, Now(), DateTime.Parse(Mytime)) thanks anyways... (Almost felt like taking my shoe off and smash some statue too!!!!:p) Edited April 10, 2003 by Ariez Quote Auto-suggestion: "I have a life" Uncontroled thinking: "So what the.."
*Experts* Volte Posted April 10, 2003 *Experts* Posted April 10, 2003 You should not use the DateDiff function, as it is a VB6 compatability function. You should use the TimeSpan class quwiltw said. For example, Dim time1 As DateTime = DateTime.Parse("November 27 1987") Dim ts As New TimeSpan(365, 55, 3, 4) Dim newTime As DateTime = time1.Add(ts)This will take the date 11/27/87 and add 365 days, 55 hours, 3 minutes and 4 seconds to it. Quote
Ariez Posted April 10, 2003 Author Posted April 10, 2003 VolteFace, I got that class instance with a timer in it and a scheduled event in this format #hh:mm:ss tt#. On every tick event, now() is compared to the schedule. if the diff between now() and the schedule <0 the the event is fired and the timer disabled. How do I compare now() and the schedue with the timeSpan? (are you into poster or statue shoe smashing in Ontario?) Quote Auto-suggestion: "I have a life" Uncontroled thinking: "So what the.."
*Experts* Volte Posted April 10, 2003 *Experts* Posted April 10, 2003 You can use the Ticks property of the Date returned by Now() to generate a TimeSpan, and use the Subtract function of the date you wish to subtract from. For example, this finds the amount of time until 11/15/2005. Dim future As New DateTime(2005, 11, 15) Dim difference As DateTime difference = future.Subtract(New TimeSpan(Now.Ticks)) Quote
Ariez Posted April 10, 2003 Author Posted April 10, 2003 New stuff is good, i'll try to use it. This forum has helped me a lot. Thanx for the spirit... Quote Auto-suggestion: "I have a life" Uncontroled thinking: "So what the.."
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.