logindatetime(X)
Returns the date and time of the current session's login within a given time zone.
Syntax
logindatetime(X)
Input
Argument | Type | Description |
---|---|---|
X |
integer | A whole number between -11 and 11 (or column name containing such values),
representing a time zone, where 0 represents GMT For example:
|
Return Value
Returns the decimal value corresponding to the date+time of the current session's login within the given time zone.
If the input values are not in one of the supported formats listed above, the function returns an erroneous or illogical output.
Example
The following example gets the login date and time using the
logindatetime(X)
function.
<base table="default.lonely" label="Example: logindatetime(X)"/> <willbe name="login_date_time" value="logindatetime(-5)" label="Login`Date+Time" format="type:datehms24"/> <colord cols="login_date_time"/>
datehms24
format type so
that the date+time will appear as a date and time
(03/17/16_15:02:12) and not as a decimal number
(-6,863.37347286349).Example: Elapsed time since login
The following example uses datetime(X;Y)
to create a
date+time value from two columns in the
pub.demo.weather.wunderground.observed_hourly table:
date
and time
. It then determines the login date and
time of the user (using the logindatetime(X)
function) and calculates the
number of days, hours, minutes, and seconds that have elapsed since the time the user logged
in.
<base table="pub.demo.weather.wunderground.observed_hourly" label="Example: Elapsed time since login"/> <sel value="(zipcode='10017')"/> <willbe name="observed_date_time" value="datetime(date;time)" label="Observed Date/Time" format="type:datehms24"/> <willbe name="login_date_time" value="logindatetime(-5)" label="Login Date/Time" format="type:datehms24"/> <willbe name="login_date" value="logindate(-5)" label="Login Date" format="type:date"/> <colord cols="zipcode,date,time,observed_date_time,login_date_time"/> <willbe name="delta" value="login_date_time-observed_date_time" format="dec:2"/> <willbe name="elapsed_days" value="if(delta < 1; 0; days(date;login_date))" label="Elapsed Days"/> <willbe name="elapsed_hours" value="time(delta)" label="Elapsed Time" format="type:hms24"/>