When querying from the specific database, you will need to know the timezone for that database. With that information, you will need to add the timezone to the end of the string that is returned from the query.
For example. If I have a SQL server returning dates in EST timezone, I would query the database:
SELECT time FROM some_table;
The resulting time might be '2017-06-05 13:15:45'
I would append the EST so that it would be '2017-06-05 13:15:45 EST'. Now I can deduce the date into the current QIE timezone.
Once I have the date in the current timezone, I can convert it to 'UTC' by following the examples in this KB article: https://www.qvera.com/kb//index.php/127/is-there-a-way-to-change-the-time-zone-of-a-date-time-value
Here is a code example:
// get the date from the query
var sqlDate = qie.doConditionQuery('myDatabase', 'SELECT timestamp FROM some_table');
// append the timezone from the SQL server. In this case the server 'myDatabase' with the timezone of 'EST'
var sqlDate = sqlDate + ' EST';
// now conver thte date to the local QIE date
var qieDate = qie.deduceDate(sqlDate);
// now we need to output the date as a formatted UTC date
var utcTimeFormat = new java.text.SimpleDateFormat('yyyy-MM-dd HH:mm:ss.SSSZ');
utcTimeFormat.setTimeZone(java.util.TimeZone.getTimeZone("UTC"));
var utcDate = utcTimeFormat.format(qieDate);
// utcDate can be placed in the message and the receiving system can process it as UTC