Quantcast
Channel: WinDev Forum
Viewing all articles
Browse latest Browse all 1914

[WD23] DateTime / Duration (2 replies)

$
0
0
Hi,
there's an unexpected difficulty (only for me?) in calculating a duration. The problem is simple.

A Date item (defined for YYYYMMDDhhmmssccc) of the file HISTORY receives the Log-in Date and Time:
GPW_HISTORY.HISTORY_LOGIN = DateToString(DateSys(),"YYYYMMDD")+TimeToString(TimeSys(),"HHMMSS")

Same goes for a logout. Whenever the main menue is closed then the log-out is recorded in another Date item
GPW_HISTORY.HISTORY_LOGOUT = DateToString(DateSys(),"YYYYMMDD")+TimeToString(TimeSys(),"HHMMSS")

Of course, there will be no logout Date+Time if the program crashes somewhen or as long as the user's session has not been terminated.

A table control shows both items correctly in their columns (defined as Dates, returning YYYYMMDDhhmmss). One could be happy with that, but now I want to show the exact time which elapsed between a Log-in and Log-out in a third column of the table.

I created a column with type of Duration, which will return DHHMMSSLLL and displays +2d d H h MM m SS s CCC ms. Using DateTimeDifference(..) of the LOGOUT / LOGIN datetime columns shows incorrect results! Does any of you know what's going on here or is there a solution??

The code
IF Table.HISTORY_LOGIN <> Null AND Table.HISTORY_LOGOUT <> Null THEN
	DateTimeLOGIN = Table.HISTORY_LOGIN
	DateTimeLOGOUT = Table.HISTORY_LOGOUT
	MyDuration = DateTimeDifference(DateTimeLOGIN,DateTimeLOGOUT)
	Table.DAUER = MyDuration
ELSE
	Table.DAUER = 0
END
[attachment 2712 LoginDauer.png]

Viewing all articles
Browse latest Browse all 1914

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>