CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    Join Date
    Dec 2009
    Posts
    6

    VB 2008 Compairing 2 date and times

    Hi all im struggling a bit and was wondering if anyone can help. Im looking to compair 2 sets of datess and times, for examp2 textbox1 27/02/1980 23:00 and text box 2 having the real time date and time. But instead off having years days hours mins and seconds i want to display how many seconds has passed between the two date and times. Can anyone show me how this is done as i have no clue where to start.

    many thanks.

    alex

  2. #2
    Join Date
    Jul 2001
    Location
    Sunny South Africa
    Posts
    11,284

    Re: VB 2008 Compairing 2 date and times

    One option is to use the DateDiff method :

    Code:
            MessageBox.Show(DateDiff("s", CDate(TextBox1.Text), CDate(TextBox2.Text)))

  3. #3
    Join Date
    Dec 2009
    Posts
    6

    Re: VB 2008 Compairing 2 date and times

    Hi i tried that and got invalidcastexeption was unhandled then on othe next line Conversion from string "" to type 'Date' is not valid. appologies for having to pester you again. Alex

  4. #4
    Join Date
    Dec 2009
    Posts
    6

    Re: VB 2008 Compairing 2 date and times

    Quote Originally Posted by Zanderman1980 View Post
    Hi i tried that and got invalidcastexeption was unhandled then on othe next line Conversion from string "" to type 'Date' is not valid. appologies for having to pester you again. Alex
    its ok i got it now,

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured