Parameters
date |
string | A serialized Campaign timestamp, e.g. a date attribute read from a query. |
Returns
| Date | A JavaScript Date. |
Examples
A date attribute read from a query comes back as a string, not a Date. Calling .getTime() or comparing it directly wonβt behave as expected: parse it first.
parseTimeStamp parses a Campaign timestamp string into a JavaScript Date, so you can compare it, do arithmetic on it, or store it as a workflow pointer. It is the read counterpart of π formatDate.
Read a date from a query
var rows = sqlSelect(
"delivery, @id:long, @lastModified:datetime",
"SELECT iDeliveryId, tsLastModified FROM NmsDelivery WHERE iState = $(l)",
"",
12,
);
var last = parseTimeStamp(rows.delivery[0].@lastModified); // string β Date
var ageMs = getCurrentDate().getTime() - last.getTime(); // now safe to compute
Time zones:
parseTimeStampreads the value in the instance time zone. For UTC arithmetic, stock code wraps it inconvertToUTC(parseTimeStamp(...)).
See also
-
π formatDate- Format a date into a string using a Campaign date mask. Opposite of parseTimeStamp. -
π sqlSelect- Run a raw SQL SELECT and returns an XML collection. Prefer queryDef for higher abstraction.