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: parseTimeStamp reads the value in the instance time zone. For UTC arithmetic, stock code wraps it in convertToUTC(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.