Date and Time Variables

If you need to change the SQL query dynamically, you can use predefined variables. BellaDati currently supports functions to get date, time or timestamp in user defined formats:

Name

Description

Examples

$date(dateString)

Evaluates the dateString and outputs the date in yyyy-MM-dd format. The dateString

$date(now + 5d -4w)
$date(2011-01-01 + 5d -4w)
$date(actualMonth -1d)

$date(dateString, format)

Works like $date(dateString), but output format is controlled by format parameter

$date(now + 5d -4w, dd-MM-yyyy)
$date(2011-01-01 + 5d -4w, MMyyyy)
$date(actualMonth -1d, yyyy-dd-MM)

$time(timeString)

Evaluates the timeString and outputs the resulting time in HH:mm:ss format

$time(now)
$time(actualhour)
$time(actualminute)

$time(timeString, format)

Works like $time(timeString), but output format is controlled by format parameter

$time(now, HH:mm:ss)
$time(actualhour, MMss)
$time(actualminute, HHmmss)

$timestamp()

Returns the current time stamp value

$timestamp()
$lastSuccessfulImport()
Returns time stamp with last successful import
$lastSuccessfulImport()

$firstValue(L_ATTRIBUTE_CODE)

Returns the lowest value (sorted ascending) of the attribute specified by attribute ID stored in the current data set.

Returns empty string if there are no data or the attribute code is not valid.

$firstValue(L_ID) //returns 123456

$firstValue(L_DATE_ATTRIBUTE) //returns 2013-01-01
$firstValue(L_TIME_ATTRIBUTE) //returns 10:00:54

$lastValue(L_ATTRIBUTE_CODE)

Returns the highest value (sorted descending) of the attribute specified by attribute ID stored in the current data set.

Returns empty string if there are no data or the attribute code is not valid.

$lastValue(L_ID) //returns 123456

$lastValue(L_DATE_ATTRIBUTE) //returns 2013-12-31
$lastValue(L_TIME_ATTRIBUTE) //returns 23:59:59
$firstValue(DATASET_CODE, L_ATTRIBUTE_CODE)Returns the lowest value (sorted ascending) of the attribute specified by attribute ID stored in the referenced data set.$firstValue(NEW_DATA_SET__SQL_DATABAS_4, L_ATT)
$lastValue(DATASET_CODE, L_ATTRIBUTE_CODE)Returns the highest value (sorted descending) of the attribute specified by attribute ID stored in the referenced data set.$lastValue(NEW_DATA_SET__SQL_DATABAS_4, L_ATT)

When using the variables in the SQL query, you should make sure that the variable is placed in the quotes, so it will be used as string.

 

An example of such a condition can be: WHERE id > '$lastValue(L_ID)'

DateString

TimeString