Thursday 17 September 2015

MBO Date Formats

Sometimes we need to filter the MboSet records based on dates.
  • By using MXFormat.dateToSQLString(Date d) you can get the date format as "yyyy-MM-dd".

For example:
MboSetRemote mboSetRemote = getMboSet("ASSET");
mboSetRemote.setWhere(MXFormat.dateToSQLString(getDate("STATUSDATE")));

Here MXFormat.dateToSQLString will return date as string and format is '2015-09-17' (with single quotes).

  • If your database is using different date format, then update it in system properties mxe.db.format.date and use SQLFormat.getDateFunction(Date d)

For example:
MboSetRemote mboSetRemote = getMboSet("ASSET");
mboSetRemote.setWhere(SQLFormat.getDateFunction(getDate("STATUSDATE"));

Here SQLFormat.getDateFunction will return date as string in two ways:

1. If mxe.db.format.date is not null/blank then it will return string with given date format in this property.
for example: If mxe.db.format.date is dd-MM-yyyy, then return string will be '17-09-2015' (with single quotes)
2. If mxe.db.format.date is null/blank, then it will return same as MXFormat.dateToSQLString method, i.e. '2015-09-17' (with single quotes).

Hope it helps :)

No comments:

Maximo SOAPUI error javax.xml.ws.WebServiceException

SOAPUI error while sending payload to below url (in cluster environment) http://localhost:9080/meaweb/services/MXASSET Error : <f...