Skip to content

pQuery.setDate

Signature: pQuery.setDate(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 Date value using the default time zone of the virtual machine that is running the application.

Note

The JDBC driver converts this to an SQL DATE 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 or Date 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 date_of_birth = :birth_date where patient_id = 1"
);

// Example: value as String (ISO date format)
pQuery.setDate("birth_date", "2001-05-15");

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


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

var birthDate = qie.deduceDate("2001-05-15"); // returns a Date object
pQuery.setDate("birth_date", birthDate);

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


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

pQuery.setDate(":birth_date", "2001-05-15");

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