1. Home
  2. Setting the Timestamp Pattern at the Application Level

Setting the Timestamp Pattern at the Application Level

With the new date/time enhancement in m-Power, dates and timestamps can be displayed in any format needed and every database can be queried much easier.  However, timestamps are defined at the dictionary level.  What happens if you need to only display/search on the date portion of a timestamp in one particular table?  The following scenario explains how to set the dBTimestampPattern for an individual application.

Example Scenario

You have many different timestamp fields within your data dictionary. After finding out the correct timestamp format from your database administrator and plugging that format into the dBTimestampPattern, your apps run correctly. However, you have another timestamp field in which the time portion of the field is not used, and as a result you would only like to display the date at runtime. Normally, setting the timestamp format to a date only format (i.e. yyyy-MM-dd) will throw an error when trying to use this field in any filter or record selection. Instead, you can set the dBTimestampPattern at the application level in order to only use the date portion of the timestamp.

Note: This will only work on a field where the time is zero for every record (i.e. 2011-12-02 0:00:00.000).

  1. First, open the servlet properties file under Admin –> Edit Data Dictionary Files –> Servlet Properties. Copy the following code from the end of the file:

  2. Next, in your application open the Application Properties and set the edit_type to Text Editing Only.  Now, open m-Painter for this application and change the page dropdown to your application properties file (for Inquiry 10, you will look for I00010p.xml). Then, scroll to the end of this file and paste the two attributes in the “Others” section, being sure to edit the values appropriately, so the application properties file would now look like this:

    Note: Notice how the dBTimestampPattern has been modified from “yyyy-MM-dd hh:mm:ss.SSS” to “yyyy-MM-dd” by deleting the time portion of the formatting. This is done so only the date portion of the timestamp will be utilized at runtime.
  3. Save this file and confirm that it has been changed by opening Application Properties within the interface, clicking on the “Others” tab and verifying that both properties are now included. Now, your timestamp field will be defined at the application level which will allow you to use any date format for your timestamp field.
Updated on May 12, 2023

Was this article helpful?