Skip to content

pQuery.setTimestamp

Signature: pQuery.setTimestamp(parameterName, value)

Returns: ParameterizedQuery pQuery - this ParameterizedQuery object. To see what methods can be used on a ParameterizedQuery, refer to the 'Parameterized Query' functions.

Sets the parameterName to the given java.sql.Timestamp value.

Note

The JDBC driver converts this to an SQL TIMESTAMP value when it sends it to the database.

Note

The parameterName may include the parameter prefix character (colon ':' or at sign '@') but is not required. For example: ':fieldValue' and 'fieldValue' will reference the same named parameter.

Parameters

Type Name Description Default
String parameterName the name of the parameter
String, Date, or Timestamp value the value to use for parameterName

Example

// Create the pQuery object with the SQL to be called
var pQuery = qie.getParameterizedQuery(
   "update patient set last_seen = :birth where patient_id = 1"
);

// Example: value as String (yyyy-MM-dd HH:mm:ss format)
pQuery.setTimestamp("birth", "2025-01-05 07:15:00");

// Execute the query
var queryResult = pQuery.doQuery("EMR Database");


// Example: value as Date
pQuery = qie.getParameterizedQuery(
   "update patient set last_seen = :birth where patient_id = 1"
);

var timestampDate = qie.deduceDate("2025-01-05 07:15:00"); // Date Object
pQuery.setTimestamp("birth", timestampDate);

queryResult = pQuery.doQuery("EMR Database");


// Example: value as Timestamp
pQuery = qie.getParameterizedQuery(
   "update patient set last_seen = :birth where patient_id = 1"
);

var sqlTimestamp = new java.sql.Timestamp(qie.getSystemTimeMilliseconds());
pQuery.setTimestamp("birth", sqlTimestamp);

queryResult = pQuery.doQuery("EMR Database");


// Example: parameterName with prefix and value as String
pQuery = qie.getParameterizedQuery(
   "update patient set last_seen = :birth where patient_id = 1"
);

pQuery.setTimestamp(":birth", "2025-01-05 12:30:45");

queryResult = pQuery.doQuery("EMR Database");