Datetime calculation store and subtract Starttime and Endtime Please Help
Posted: Sun Feb 23, 2020 12:26 pm
Hi Guys,
Can someone please help me to code this so that it will work , I have a starttime and a endtime both in a label on a form, When I stop then I want to calculate the actualtime span between start and stop in a 3rd label. I have tried many ways but encounter errors like Datediff does not exist in current context. I have tried defining 2 fields to move the date to and then subtract this does not work either I cannot move the label date to the external fields. I woujld appreciate a example code in X# and which -Net classes do I need for this ??
Thanks my simple code is below.
Raymond
METHOD Stop_ButtonClick(sender AS System.Object , e AS System.EventArgs) AS VOID
LOCAL EndTime AS datetime
LOCAL Duration AS Timespan
oLabel3:Text := Time()
oTimer1:Enabled := FALSE
SELF:oLabel4.Text := Datediff("h",StartTime,endTime)
Messagebox.show(SELF:oLabel4.Text:ToString())
RETURN
METHOD Start_ButtonClick(sender AS System.ObMETHOD Stop_ButtonClick(sender AS System.Object , e AS System.EventArgs) AS VOID
LOCAL EndTime AS datetime
LOCAL Duration AS Timespan
oLabel3:Text := Time()
oTimer1:Enabled := FALSE
SELF:oLabel4.Text := Datediff("h",StartTime,endTime)
Messagebox.show(SELF:oLabel4.Text:ToString())
RETURNnt contextject , e AS System.EventArgs) AS VOID
LOCAL StartTime AS datetime
oTimer1:Enabled := TRUE
oLabel2:Text := Time()
RETURN
METHOD Stop_ButtonClick(sender AS System.Object , e AS System.EventArgs) AS VOID
LOCAL EndTime AS datetime
LOCAL Duration AS Timespan
oLabel3:Text := Time()
oTimer1:Enabled := FALSE
SELF:oLabel4.Text := Datediff("h",StartTime,endTime)
Messagebox.show(SELF:oLabel4.Text:ToString())
RETURN
Can someone please help me to code this so that it will work , I have a starttime and a endtime both in a label on a form, When I stop then I want to calculate the actualtime span between start and stop in a 3rd label. I have tried many ways but encounter errors like Datediff does not exist in current context. I have tried defining 2 fields to move the date to and then subtract this does not work either I cannot move the label date to the external fields. I woujld appreciate a example code in X# and which -Net classes do I need for this ??
Thanks my simple code is below.
Raymond
METHOD Stop_ButtonClick(sender AS System.Object , e AS System.EventArgs) AS VOID
LOCAL EndTime AS datetime
LOCAL Duration AS Timespan
oLabel3:Text := Time()
oTimer1:Enabled := FALSE
SELF:oLabel4.Text := Datediff("h",StartTime,endTime)
Messagebox.show(SELF:oLabel4.Text:ToString())
RETURN
METHOD Start_ButtonClick(sender AS System.ObMETHOD Stop_ButtonClick(sender AS System.Object , e AS System.EventArgs) AS VOID
LOCAL EndTime AS datetime
LOCAL Duration AS Timespan
oLabel3:Text := Time()
oTimer1:Enabled := FALSE
SELF:oLabel4.Text := Datediff("h",StartTime,endTime)
Messagebox.show(SELF:oLabel4.Text:ToString())
RETURNnt contextject , e AS System.EventArgs) AS VOID
LOCAL StartTime AS datetime
oTimer1:Enabled := TRUE
oLabel2:Text := Time()
RETURN
METHOD Stop_ButtonClick(sender AS System.Object , e AS System.EventArgs) AS VOID
LOCAL EndTime AS datetime
LOCAL Duration AS Timespan
oLabel3:Text := Time()
oTimer1:Enabled := FALSE
SELF:oLabel4.Text := Datediff("h",StartTime,endTime)
Messagebox.show(SELF:oLabel4.Text:ToString())
RETURN