Jump to content
Xtreme .Net Talk

Recommended Posts

Posted


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?

Auto-suggestion: "I have a life"

Uncontroled thinking: "So what the.."

Posted (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 by Ariez

Auto-suggestion: "I have a life"

Uncontroled thinking: "So what the.."

Posted (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 by Ariez

Auto-suggestion: "I have a life"

Uncontroled thinking: "So what the.."

  • *Experts*
Posted

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.

Posted

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?)

Auto-suggestion: "I have a life"

Uncontroled thinking: "So what the.."

  • *Experts*
Posted

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))

Posted

New stuff is good, i'll try to use it.

This forum has helped me a lot.

Thanx for the spirit...

Auto-suggestion: "I have a life"

Uncontroled thinking: "So what the.."

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...