Solved

How to combine the Hours and Minutes from Datediff  in order to update access DB field?

Posted on 2006-07-22
2
334 Views
Last Modified: 2012-05-05
I have an ASP which is logging Overtime for employees. It pulls the ClockInTime and ClockOutTime from an Access DB.  
The page uses datediff to find the hours and minutes between ClockInTime and ClockOutTime.
When the employee clock's out, I display the total time in Hours and Minutes they worked.
I also want to insert this to the TotalOT field in my database.
When I try updating the TotalOT field in my table, I keep getting the "Data type mismatch.."  error.
I think this is because datediff is splitting up hours and Minutes.
I tried just using minutes rather than attempting to combine Hours and Minutes, but that still returns the data type error.
The TotalOT field is set as Date/Time - short
Does anyone know how I could combine the Hours and Minutes from Datediff  so I could update this DB field?


sql = "UPDATE TimeSheet  SET  TotalOTMins ='" & TotalM  & "'   WHERE NAME  = ('"& Name &"') AND DT = (#" & todaysDate &"#) AND isNull(TotalOTMins)"

'Pull clock in / out times from database
            Cout = rs("ClockOutTime")
            Cin = rs("ClockInTime")  

'Format Date so we can get the amount of OT worked
            Cin = FormatDateTime(Cin, vbShortTime)
            Cout = FormatDateTime(Cout, vbShortTime)

Display the total OT worked for this user's session
            response.write "You have worked " & TotalH & ":" & TotalM & " Hours/Minutes of overtime for this session."

set rs = connection.execute(sql)
0
Comment
Question by:cubicalmonkey
2 Comments
 
LVL 46

Accepted Solution

by:
fritz_the_blank earned 125 total points
ID: 17160468
I think that the issue here is that the total overtime is not really a date but a number of minutes or hours.  I suppose that you could create a date instead by trying to insert something like:

 TotalOTMins = DateAdd("n",TotalM,"2006/07/22 00:00:00")

and then you could pull out the overtime that way.

If I were doing this, however, I would change the  TotalOTMins  to an integer field.

FtB
0
 

Author Comment

by:cubicalmonkey
ID: 17176811
Thanks Fritz,
I was able to figure everything out with your suggestions.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

I would like to start this tip/trick by saying Thank You, to all who said that this could not be done, as it forced me to make sure that it could be accomplished. :) To start, I want to make sure everyone understands the importance of utilizing p…
This demonstration started out as a follow up to some recently posted questions on the subject of logging in: http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Q_28634665.html and http://www.experts-exchange.com/Programming/…
Windows 10 is mostly good. However the one thing that annoys me is how many clicks you have to do to dial a VPN connection. You have to go to settings from the start menu, (2 clicks), Network and Internet (1 click), Click VPN (another click) then fi…
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…

910 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now