.Net Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsProgramming Languages - More.Net Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old June 25th, 2012, 11:47 AM
Rafic Rafic is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2012
Posts: 1 Rafic User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 31 m 5 sec
Reputation Power: 0
(VS 2010) Determine time difference

Hello,

I'm stuck on the part where I need to determine the time difference from my database. Basically data gets recorded onto the database from a different form and gets displayed on this form...

http ://i.imgur.com/tOgwJ.png

What I need to do is,
1. calculate the time worked from the start of the week day till the end of it. So, in this case the time worked should be 1:36:13, not the 12 hours...

2. Is there a way to keep on calculating when the day changes and start off with the same procedure as mentioned above (i.e. start from the 1st entry on Friday and calculate till the last entry of that day).

The code:

PHP Code:
Public Class frmDisplay


    
Private Sub Form1_Load(ByVal sender As System.ObjectByVal e As System.EventArgsHandles MyBase.Load
        
'TODO: This line of code loads data into the 'TimelogDataSet.timeLog' table. You can move, or remove it, as needed.
        Me.TimeLogTableAdapter.Fill(Me.TimelogDataSet.timeLog)

        Me.dtpStart.Value = DateTime.Now.AddDays(-7)
        Me.dtpEnd.Value = DateTime.Now.Date

        TimeLogBindingSource.Filter = String.Format("currentDate >= #{0:M/dd/yyyy}# AND currentDate <= #{1:M/dd/yyyy}#", dtpStart.Value = DateTime.Now.AddDays(-7), dtpEnd.Value)

    End Sub



    Private Sub DateTimePicker2_ValueChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles dtpEnd.ValueChanged

    End Sub

    Private Sub dtpStart_ValueChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles dtpStart.ValueChanged

    End Sub

    Private Sub btnDisplay_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnDisplay.Click

        Dim difference As TimeSpan = dtpEnd.Value - dtpStart.Value

        TimeLogBindingSource.Filter = String.Format("currentDate >= #{0:M/dd/yyyy}# AND currentDate <= #{1:M/dd/yyyy}#", dtpStart.Value, dtpEnd.Value)
        Me.lblDisplay.Visible = False

        Me.lblTimeWorked.Text = DateDiff(DateInterval.Minute, dtpStart.Value, dtpEnd.Value)
        If difference.Minutes <> 0 Then
            Me.lblTimeWorked.Text = difference.Hours.ToString() & " hours." & " and " & difference.Minutes.ToString() & " minutes."

        End If

    End Sub

    Private Sub btnClear_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnClear.Click
        '
TimeLogBindingSource.Filter String.Format("currentDate >= #{0:M/dd/yyyy}# AND currentDate <= #{1:M/dd/yyyy}#"dtpStart.Value DateTime.NowdtpEnd.Value)
    
End Sub

End 
Class 


I'd appreciate your help.

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - More.Net Development > (VS 2010) Determine time difference

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap