Specifying Datetime Formats

You can specify the acceptable format for dates in a file, if you are using a system that reads data from a file.

The Open adapter rejects dates that are not in the specified format. If you do not specify an acceptable datetime format, the adapter understands datetime values only with the format yyyyMMdd or yyyyMMdd HH:mm:ss, and rejects any other datetime data.

If you specify the format in the form of a template string, use special identifiers for day, year, month, and so on, along with formatting characters. Use uppercase H for hour to ensure the use of a 24-hour clock.

Datetime Format Identifiers
Character Description Typical Usage
y A digit of year yyyy
M A digit of month MM
d A digit of day dd
H A digit of hour (0 – 23) HH
m A digit of minute mm
s A digit of second ss
S A digit of millisecond SS

If your input data contains letters, enter them in single quotation marks. For example, if the input has strings like Day:2003-12-29 Time:10:22-00, specify a datetime format of 'Day' :yyyy-MM-dd 'Time' :HH:mm:ss. Entering the format in this way prevents the Open adapter from mistaking the letters as formatting instructions.

Examples of specifying datetime formats:
  • If you read dates from a file formatted as 2003/06/29, where the year is 2003, the month is 06 (June), and the day is 29, enter the datetime format as yyyy/MM/dd.
  • If you read dates from a file formatted as 29-06-2003 19:12:45, where the day is 29, the month is 06 (June), the year is 2003, and the time is 7:12:45 PM, enter the datetime format as dd-MM-yyyy HH:mm:ss.
  • If MQ-Series passes a value for MQPutDateTime in the format of 2003-06-29 19:12:45.493, where the year is 2003, the month is 06 (June), the day is 29, and the time is 7:12:45 PM and 493 milliseconds, enter the datetime format as yyyy-MM-dd HH:mm:ss.SSS.
Note: The Open adapter it strips off (ignores) any milliseconds that it reads through datetime.
Related concepts
Valid Time Zones for the Open Adapter