jt_muzix
Newcomer
Hello, I'm working on a timeclock program for a company I work for. I'm developing it under vb.net. The problem I'm having is that the company only calculates quarter of an hour intervals. So if the time in is =>##:08 it automaticall goes to ##:15. If its >5:08 it goes back to 5:00. if its => ##:23 it automatically goes to ##:30. If its => ##:37 it automatically goes to ##:45. It its => ##:53 it automatically goes to the next hour. I can calculate the hours with datediff(dateinterval.minute, datin, datout). However, I'm not sure how to round according to the above rules that I have mentioned here. Here is the code I have so far. If anyone can help me implement the rounding thing, please email me at
jt_muzix@execpc.com.
Thanks
Jason
Private Sub cmdcalc_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdcalc.Click
Dim mondatin As DateTime
Dim mondatout As DateTime
Dim tuedatin As DateTime
Dim tuedatout As DateTime
Dim wenddatin As DateTime
Dim wenddatout As DateTime
Dim thursdatin As DateTime
Dim thursdatout As DateTime
Dim fridatin As DateTime
Dim fridatout As DateTime
Dim satdatin As DateTime
Dim satdatout As DateTime
Dim sundatin As DateTime
Dim sundatout As DateTime
'variables assigned for each day
Dim monhours As Double
Dim tuehours As Double
Dim wendhours As Double
Dim thurshours As Double
Dim frihours As Double
Dim sathours As Double
Dim sunhours As Double
'variables for totals
Dim totalhours As Integer
Dim hour As Double
'conversions
mondatin = Convert.ToDateTime(txtmonin.Text)
mondatout = Convert.ToDateTime(txtmonout.Text)
monhours = DateDiff(DateInterval.Minute, mondatin, mondatout)
tuedatin = Convert.ToDateTime(txttuein.Text)
tuedatout = Convert.ToDateTime(txttueout.Text)
tuehours = DateDiff(DateInterval.Minute, tuedatin, tuedatout)
wenddatin = Convert.ToDateTime(txtwendin.Text)
wenddatout = Convert.ToDateTime(txtwendout.Text)
wendhours = DateDiff(DateInterval.Minute, wenddatin, wenddatout)
thursdatin = Convert.ToDateTime(txtthursin.Text)
thursdatout = Convert.ToDateTime(txtthursout.Text)
thurshours = DateDiff(DateInterval.Minute, thursdatin, thursdatout)
fridatin = Convert.ToDateTime(txtfriin.Text)
fridatout = Convert.ToDateTime(txtfriout.Text)
frihours = DateDiff(DateInterval.Minute, fridatin, fridatout)
satdatin = Convert.ToDateTime(txtsatin.Text)
satdatout = Convert.ToDateTime(txtsatout.Text)
sathours = DateDiff(DateInterval.Minute, satdatin, satdatout)
sundatin = Convert.ToDateTime(txtsunin.Text)
sundatout = Convert.ToDateTime(txtsunout.Text)
sunhours = DateDiff(DateInterval.Minute, sundatin, sundatout)
'calculation to display total hours
totalhours = (monhours + tuehours + wendhours + thurshours + frihours + sathours + sunhours)
lbltothours.Text = totalhours / 60
End Sub
jt_muzix@execpc.com.
Thanks
Jason
Private Sub cmdcalc_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdcalc.Click
Dim mondatin As DateTime
Dim mondatout As DateTime
Dim tuedatin As DateTime
Dim tuedatout As DateTime
Dim wenddatin As DateTime
Dim wenddatout As DateTime
Dim thursdatin As DateTime
Dim thursdatout As DateTime
Dim fridatin As DateTime
Dim fridatout As DateTime
Dim satdatin As DateTime
Dim satdatout As DateTime
Dim sundatin As DateTime
Dim sundatout As DateTime
'variables assigned for each day
Dim monhours As Double
Dim tuehours As Double
Dim wendhours As Double
Dim thurshours As Double
Dim frihours As Double
Dim sathours As Double
Dim sunhours As Double
'variables for totals
Dim totalhours As Integer
Dim hour As Double
'conversions
mondatin = Convert.ToDateTime(txtmonin.Text)
mondatout = Convert.ToDateTime(txtmonout.Text)
monhours = DateDiff(DateInterval.Minute, mondatin, mondatout)
tuedatin = Convert.ToDateTime(txttuein.Text)
tuedatout = Convert.ToDateTime(txttueout.Text)
tuehours = DateDiff(DateInterval.Minute, tuedatin, tuedatout)
wenddatin = Convert.ToDateTime(txtwendin.Text)
wenddatout = Convert.ToDateTime(txtwendout.Text)
wendhours = DateDiff(DateInterval.Minute, wenddatin, wenddatout)
thursdatin = Convert.ToDateTime(txtthursin.Text)
thursdatout = Convert.ToDateTime(txtthursout.Text)
thurshours = DateDiff(DateInterval.Minute, thursdatin, thursdatout)
fridatin = Convert.ToDateTime(txtfriin.Text)
fridatout = Convert.ToDateTime(txtfriout.Text)
frihours = DateDiff(DateInterval.Minute, fridatin, fridatout)
satdatin = Convert.ToDateTime(txtsatin.Text)
satdatout = Convert.ToDateTime(txtsatout.Text)
sathours = DateDiff(DateInterval.Minute, satdatin, satdatout)
sundatin = Convert.ToDateTime(txtsunin.Text)
sundatout = Convert.ToDateTime(txtsunout.Text)
sunhours = DateDiff(DateInterval.Minute, sundatin, sundatout)
'calculation to display total hours
totalhours = (monhours + tuehours + wendhours + thurshours + frihours + sathours + sunhours)
lbltothours.Text = totalhours / 60
End Sub