Hey folks,
I'm working on a formula to let people in our company manage vacation time, flex time, etc. I've built the following code below, and it works to a degree -- if I put in '8:58' in for a start time instead of '8:30', it tells me that I've used 0.5 flex hours. However, if I put '8:00' I don't get -0.5 (which I want), I get 16.5 hours, and no idea how this is happening or how to fix it.
Help?
var vButtonOn as int
var vOK as int
var vDate as date = @serverdate()
var vStart as time
var vEnd as time
var vFlex as double
var vFlexTotal as double
var vAbsTotal as double
var vVacTotal as double
var vStaffStats as string
var vTest as double
notifyform(0)
vStaffStats = @xlookupsourcelist(@FN, @userid, "Staff Screen!StaffRef","StAbsCt;StPrsCt;StVacCt")
// 2011-01-11 BW ADDED SECURITY - USERS CAN'T ACCESS STAFF SCREEN
if @group <> "Users" then vOK = 0
if @userid = "BW" then vOK = 1
if @Xlookupsourcelist(@FN, @userid, "Staff Screen!StaffRef", "StAccFlex") = 1 then vOK = 1
if vOK = 1
{
vFlexTotal = @accessstringarray(vStaffStats,2)
vDate = @promptforuserinput("Flex Date?",vDate)
vStart = @promptforuserinput("Start Time?", "8:30:00")
vEnd = @promptforuserinput("End Time?", "17:00:00")
vFlex = @totime(vStart) - @totime("8:30:00")
vFlex = @round((vFlex/15),0) * 15 / 60
Writeln("You are using " + vFlex + " of your accumulated " + vFlexTotal + " time")
}
ELSE
{
@MsgBox("","You Don't Have Access to This Function","")
}