Configure DD MMM YYYY Date Format on Siemens MP277 Touch Panels

David Krause18 min read
HMI ProgrammingSiemensTutorial / How-to
Licensed PE Working through this on a live machine? A Maine-licensed engineer can take it from here — included with IMD hardware, by the hour for everything else. Book an engineer

Overview

The Siemens SIMATIC MP277 Touch Panel, part of the SIMATIC HMI Multipanels family, ships with WinCC flexible 2007 / 2008 SPx as the configuration environment. Although the runtime exposes a Regional Settings dialog (Control Panel > Regional Settings), the date format short-list available there is limited to the canonical Windows NLS entries: dd.MM.yyyy, MM/dd/yyyy, yyyy-MM-dd, and a small set of locale-specific variants. The DD MMM YYYY format (for example 11 Jul 2008) is not a built-in NLS short date on any Windows CE / Windows XP Embedded image used by the MP277 firmware, so the dropdown simply does not offer it.

This limitation surfaces in two common engineering situations:

  • Operator screens in regulated industries (pharmaceutical, food & beverage, aerospace) where the regulator mandates a written-out three-letter month abbreviation in batch logs and audit trails.
  • Multilingual HMI deployments where the European format DD MMM YYYY is the corporate standard, but the deployment locale is set to English (United States) to keep HMI messages in English.

The robust solution is to bypass the Regional Settings dialog entirely and rebuild the date string in VBScript inside WinCC flexible, then push the resulting string into an internal HMI tag of type String. This article documents the canonical script, the off-by-one array bug that frequently truncates the year, the correct tag length, the I/O field wiring, the Scheduler hook for a midnight rollover, and the verification procedure for commissioning.

Engineering note: The MP277 platform is in the legacy phase of the Siemens product lifecycle. Firmware is frozen at the WinCC flexible 2008 SP3 era. New projects should consider migration to the SIMATIC Comfort Panel line (TP700 / TP900 / TP1200) running TIA Portal, but the VBScript pattern documented here remains representative of how WinCC flexible-based panels handle date-formatting workarounds.

Prerequisites and MP277 Context

Before implementing the script, confirm the following engineering prerequisites:

  1. Configuration environment: WinCC flexible 2007 SP1 or later; SP2 / SP3 recommended. The MP277 image is compatible with all three, but the project must be saved against the SP used by the runtime. Open the project, select the MP277 device in the project tree, and verify the WinCC flexible version field on the Device tab. Refer to the Siemens Industry Online Support portal for the SP release notes and compatibility matrix.
  2. Firmware/runtime version: MP277 8-inch or 10-inch Touch, with the standard WinCC flexible 2008 SPx image. The script does not depend on any optional image features; the standard CE 5.0 runtime is sufficient.
  3. Panel variants: The MP277 8-inch Touch and 10-inch Touch variants are the typical hosts for this script. The key variants (MP277 8-key, MP277 10-key) are also supported because they run the same CE image and the same VBScript engine; the script does not interact with the keys.
  4. Project transfer channel: Either Ethernet (RFC1006 / S7 routing) or USB-PPI / MPI depending on the panel variant. The transfer mode is irrelevant to the script itself, but commissioning verification requires a live panel.
  5. Operator authorization: The Scheduler and the script execution both run with the same authorization level as the project, so no extra operator rights are required.
  6. Approximate development time: 15-30 minutes for a first-time integration, 5 minutes for an experienced WinCC flexible engineer.

The MP277 uses a Windows CE 5.0 core with a subset of the .NET Compact Framework and a WinCC flexible runtime that includes the VBScript engine. The VBScript engine on the 2008 SPx image supports Option Explicit, Dim, ReDim, and the Date / Time / Day / Month / Year built-ins. FormatDateTime is also available, but its output follows the active NLS short-date table, so it cannot produce DD MMM YYYY out of the box on the en-US locale; this is why the array-lookup pattern is preferred over a single-line FormatDateTime call.

Why DD MMM YYYY Is Missing from Regional Settings

The MP277 runtime uses a subset of the Windows NLS date tables. The short date selector inside Control Panel > Regional Settings enumerates the date formats defined in the locale's sShortDate registry value, which for the en-US locale resolves to M/d/yyyy and a small variant list. The DD MMM YYYY pattern (two-digit day, three-letter month abbreviation, four-digit year) is not part of the en-US short date set, and the runtime does not surface the long date selector for the user.

Setting the locale to German (de-DE) is a common workaround for European deployments, because the German locale exposes a DD.MM.YYYY format. However, the German locale also forces:

  • Decimal separator becomes comma (,) which collides with the default English numeric displays used in recipes and setpoints.
  • Time separator becomes period (.).
  • Currency symbol becomes EUR.

This is too invasive for most plants. The script-based approach keeps the locale at en-US (or whatever the deployment requires) and rebuilds the date string locally.

For context on regional date format conventions and how the DD MMM YYYY pattern compares to ISO 8601 and other national conventions, see the Wikipedia list of date formats by country. ISO 8601 (YYYY-MM-DD) is the harmonized form recommended for cross-border data exchange, but it does not satisfy the human-readable three-letter-month requirement common in regulated batch records.

Solution Architecture: VBScript Date Formatter

The formatter is a VBScript subroutine that runs inside the HMI runtime whenever the project calls it. It performs the following sequence:

  1. Reads the system date with Date (VBScript built-in, returns today's date as a Variant of subtype Date).
  2. Extracts the day, month index, and year using Day(...), Month(...), Year(...).
  3. Looks up the three-letter English month abbreviation from a static 12-element array.
  4. Concatenates the parts with the - separator.
  5. Writes the resulting string to an internal HMI tag of type String.

The architecture is intentionally stateless: the array is rebuilt on every call to keep the script self-contained. For a 1-Hz scheduler, the cost is negligible (under 0.1% CPU on the MP277 CE image).

The architecture also includes a one-time-per-day refresh via the Scheduler and an immediate refresh on picture load via the Loaded event, ensuring the operator always sees a current date string and the year rolls over at midnight without operator intervention.

Step 1: Create the Internal String Tag

Open the project in WinCC flexible and navigate to Communication > Tags. Create a new internal tag with the parameters shown in the table.

Field Value Notes
Name strCurrentDate Use PascalCase or the project naming convention. The name is case-sensitive in VBScript.
Data type String Must be String, not WString. The MP277 CE runtime is ANSI-based; WString tags are unsupported on this platform.
Length (characters) 12 Exactly the number of visible characters in 14-Jul-2008 is 11, but the ANSI C-string used internally requires a null terminator. Setting length 10 produces the truncated display 14-Jul-200 with the 8 missing. Setting 12 provides the trailing null without risk of overrun. This is the most common commissioning defect on this pattern.
Update / Acquisition Cyclic, 1 s or On change Either is acceptable; the tag is overwritten by the script, so cyclic acquisition is redundant. On change reduces network load.
Initial value (empty) or 01-Jan-1970 Placeholder until the script runs for the first time.
String-length math: DD-MMM-YYYY has 2 (day) + 1 (dash) + 3 (month) + 1 (dash) + 4 (year) = 11 visible characters. Reserving 12 or 16 provides headroom for the trailing null terminator and future variants. Setting the length to exactly 11 visible characters typically truncates the last byte.

Step 2: Author the VBScript Subroutine

In the project tree, open Scripts > VB Scripts and create a new script named ScreenDateUpdate. Paste the following code:

'--------------------------------------------------------------
' ScreenDateUpdate
' Builds a "DD-MMM-YYYY" date string and writes it to the
' internal String tag strCurrentDate.
'
' Runtime: SIMATIC MP277, WinCC flexible 2008 SPx
'--------------------------------------------------------------
Option Explicit

' --- variable declarations
Dim dtDate
Dim nMonth
Dim astrMonth(12)

' --- month abbreviation table (index 0..11, 0 = January)
astrMonth(0)  = "Jan"
astrMonth(1)  = "Feb"
astrMonth(2)  = "Mar"
astrMonth(3)  = "Apr"
astrMonth(4)  = "May"
astrMonth(5)  = "Jun"
astrMonth(6)  = "Jul"
astrMonth(7)  = "Aug"
astrMonth(8)  = "Sep"
astrMonth(9)  = "Oct"
astrMonth(10) = "Nov"
astrMonth(11) = "Dec"

' --- read system time and extract parts
dtDate  = Date
nMonth  = Month(dtDate)

' --- assemble the formatted string
SmartTags("strCurrentDate") = Day(dtDate) & "-" & astrMonth(nMonth - 1) & "-" & Year(dtDate)

This is the corrected, final version of the script. The two critical details are: (1) the array is dimensioned with (12) in VBScript, which is actually 12 elements (index 0 through 11) - a frequent source of confusion; and (2) the lookup uses astrMonth(nMonth - 1) because Month() returns 1 for January but the array starts at 0.

The VBScript built-ins used in this script are documented in the WinCC flexible online help and in the VBScript 5.5 reference that ships with the development environment. The relevant behaviors are:

  • Date: returns the current system date as a Variant(Date). No parameters.
  • Day(variant): returns an integer 1-31. Argument must be a Date-typed Variant; if a String is passed, VBScript performs an implicit conversion.
  • Month(variant): returns an integer 1-12. The integer is 1-based, which is why the array lookup is offset.
  • Year(variant): returns a four-digit integer year. Note that on pre-2008 SP2 images, the Year built-in returned two-digit years in some locales; this was patched in 2008 SP2.

Step 3: Correct the Array Index (Off-by-One Bug)

During the integration of this pattern, an off-by-one error is the single most common defect. The two primary failure modes and their root causes are cataloged below.

Symptom Root cause Fix
Subscript out of range runtime error on a 1-12 month Lookup uses astrMonth(nMonth) directly. When nMonth = 12 (December), the index goes past the last valid element of the array (index 11). VBScript raises error 800A0009. Use astrMonth(nMonth - 1).
Display shows 14-Jul-200 with the trailing 8 truncated The string tag is too short. The visible string is 11 characters, but the ANSI buffer needs an extra slot for the null terminator. A length of 10 or 11 typically truncates the last visible character. Set tag length to 12 or higher. Do not set it to 11 or below.
Display is empty until operator clicks the I/O field The script is not wired to the Loaded event of the start view. The tag initializes only when the script is first called. Wire the script to the start picture Loaded event and to a Scheduler task.
Date rolls over at random times Scheduler is set to Cyclic 1 s instead of Daily at 00:00. Use a daily trigger at midnight.
Variable is undefined: nMonth Option Explicit is on but a variable is mis-spelled or not Dim'd. Add Dim nMonth at the top of the script, or disable Option Explicit for the test.
Object required: SmartTags The script runs in a context where SmartTags is not exposed (e.g., a function called from an external OPC client, not from the runtime). Verify the script is called from a picture event or a Scheduler, not from an external system.

Step 4: Place the I/O Field

Open the start picture (or the project Template if every screen should show the date). Insert an I/O field from the toolbox (Tools > Smart Objects > I/O Field in older WinCC flexible versions, or the right-hand toolbox in newer ones) and configure it as follows:

Property Value Notes
Tag strCurrentDate Internal String tag from Step 1.
Mode Output only Disable input to prevent operator overwrites. If input is enabled, set the field to Output and clear the Input value prompt.
Display format String Do not use a numeric format string; the tag is String-typed.
Field length (display columns) 11 Matches the visible string length. Leave one or two extra characters as visual margin.
Alignment Left Conventional for date strings.
Border / Background Optional Use a transparent background if the date is informational only.

Place the I/O field in a corner of the template so every screen inherits it. This pattern is common in pharmaceutical and food plants where the date stamp on every operator screen is an audit-trail requirement.

If the panel template is read-only, place the I/O field in the start picture and replicate the script call from each picture Loaded event. The runtime is fast enough that the cost of redundant script calls per screen transition is well under 1 ms.

Step 5: Wire the Loaded Event

Select the start picture in the project tree, open the Events tab, and click on the Loaded event. From the function list, navigate to Scripts > ScreenDateUpdate and assign it. The result is that the date is computed and pushed to the tag as soon as the runtime starts or the operator navigates back to the start picture.

Pitfall: The Loaded event of a picture in WinCC flexible fires when the picture is loaded into memory, which happens on the initial download and on every navigation to that picture. If the operator never returns to the start picture (for example, because the process runs in a single dedicated screen), the script will not run again. The Scheduler in Step 6 is the safety net.

As an alternative to the picture-level event, the script can be wired to the Loaded event of the project itself (right-click the project root in the project tree > Properties > Events). The project-level Loaded event fires once at runtime start, which guarantees the tag is populated before the operator sees the first picture, but it does not refresh on picture navigation.

Step 6: Schedule Midnight Refresh

Open Schedulers in the project tree and create a new trigger with the configuration shown below.

Field Value
Name DailyDateRefresh (or project naming convention)
Trigger type Daily
Time 00:00:00
Date range 01.01.2000 - 31.12.2099 (covers the panel lifetime)
Function ScreenDateUpdate

This guarantees that the displayed date updates exactly at midnight, even on leap-year transitions, without operator intervention. The runtime maintains its own clock; the script does not need to call any external time source.

For plants that span multiple time zones or that operate on a non-midnight shift change (e.g., 06:00 production day), the trigger time can be changed to the appropriate shift boundary. The script is agnostic to the time; it always reads the current date when called.

Verification Procedure

After the project compiles and is transferred to the MP277, perform the following verification steps. They are written as a commissioning checklist; mark each item before sign-off.

  1. Compile and transfer: From WinCC flexible, run Project > Compiler > All (with consistency check). Resolve any error. Use Transfer > Transfer to push the project to the panel over Ethernet or MPI.
  2. Runtime start: After the panel reboots, observe the start picture. The date I/O field should display the correct value within one second, e.g. 11-Jul-2008.
  3. String-length check: Verify the year shows all four digits. If the field reads 14-Jul-200, return to Step 1 and increase the tag length.
  4. Midnight rollover: On the Scheduler, temporarily change the trigger time to one minute in the future (e.g. 14:23:00). Wait for the trigger and confirm the value updates. Restore the trigger to 00:00:00.
  5. Month transition: Set the panel system clock to 31-Dec-YYYY 23:59:00 and watch for the year rollover on the trigger. Restore the system clock.
  6. Subscript check: With diagnostics enabled on the panel, cycle through the month boundaries (or set the system clock to 15-Dec, 16-Dec, etc.) and confirm no Subscript out of range error appears in the diagnostic buffer.
  7. Regional side-effect check: Verify that the decimal separator used in numeric fields (recipe values, setpoints) is still a period (.) and not a comma. If the comma is showing, the locale has accidentally been changed to de-DE during deployment; restore it to en-US.

Troubleshooting Matrix

Symptom Likely cause Diagnostic Fix
Field is empty on startup Script not wired to start picture Loaded event Check Events tab of start picture Wire the script to the Loaded event
Field is empty after midnight Scheduler not enabled or wrong function Open Schedulers; confirm trigger status = Active Reassign ScreenDateUpdate to the trigger
Last character truncated Tag length too short Open Communication > Tags > strCurrentDate; check Length Set length to 12 or higher
Subscript out of range Index off-by-one: lookup uses nMonth directly Open the script and search for astrMonth( Change to astrMonth(nMonth - 1)
Date shows 01-Jan-1970 forever Tag not declared as internal or wrong type Check Connection column of the tag; should be Internal Recreate the tag as internal String
Compile error: Variable not defined Option Explicit is on but a variable is mis-spelled Cross-check every variable in the script Fix the spelling, recompile
Compile error: Expected statement Smart tag reference is wrong Search for SmartTags( in the script Use SmartTags("strCurrentDate") exactly
Field shows MM/DD/YYYY instead Tag is bound to the system date variable by mistake Check the tag acquisition: should not be a system tag Recreate the tag as a fresh internal String
Date updates only on picture change Scheduler not configured; relying solely on Loaded event Open Schedulers; confirm trigger is present Add the daily Scheduler trigger at 00:00
Field shows random garbage on startup Tag initial value contains control characters or the tag length is mis-set to 1 Inspect the initial value and length Set length to 12, initial value to empty or 01-Jan-1970

Alternative: Locale-Based Workaround

If the deployment is willing to live with the trade-offs, the MP277 runtime exposes three additional short date formats when the locale is set to German (de-DE):

  • dd.MM.yyyy
  • yyyy-MM-dd
  • dd/MM/yyyy

None of these is DD MMM YYYY with the three-letter English month name. The de-DE locale also changes the decimal separator to a comma and the list separator to a semicolon, which breaks any HMI element that expects US conventions. Therefore, the German-locale shortcut is rarely viable when DD MMM YYYY is a hard requirement. The script-based approach documented above is the only way to get the exact format without changing the project numeric handling.

For deployments where the regulator accepts DD.MM.YYYY instead of DD MMM YYYY, the German locale is a valid one-line configuration change: open Control Panel > Regional Settings on the panel, set the locale to German (Germany), and select dd.MM.yyyy from the short-date list. The trade-off is the comma decimal separator; the cost of the script-based approach is the development time documented in this article.

Migration to TIA Portal Panels

When the MP277 is retired and replaced with a SIMATIC Comfort Panel (TP700, TP900, TP1200) or a Unified Panel (MTP700, MTP1000, MTP1200), the script translates directly:

  • Comfort Panel: VBScript is still supported. The same array-lookup pattern, the same SmartTags("strCurrentDate") = ... assignment, and the same Scheduler mechanism apply. The tag length and array math are identical.
  • Unified Panel: VBScript is replaced by JavaScript. The equivalent pattern is Tags("strCurrentDate").Write(Day + "-" + monthArr[Month-1] + "-" + Year); where monthArr is a 12-element JavaScript array. The Scheduler is replaced by a Scheduled task in the Unified configuration.

For new projects, prefer the Unified Panel line because the long-term support horizon extends beyond the WinCC flexible / TIA Portal V15.x generation. The script in this article is portable as-is between MP277 and Comfort Panel, which simplifies migration of legacy code.

Maintenance and Long-Term Considerations

Once the script is in production, four operational practices keep it healthy.

  1. Diagnostic buffer: Periodically read the panel diagnostic buffer via WinCC flexible Online > Diagnostics or via the Systemdiagnose view that ships with the project templates. Any Subscript out of range error indicates a coding regression.
  2. Project version: When the project is upgraded to a new WinCC flexible service pack, recompile the script. The VBScript interpreter is part of the WinCC flexible image and is consistent across SPs, but the SmartTags interface was reorganized in SP2. If the panel is replaced with a newer MP or a Comfort Panel, the script translates directly: VBScript is supported on TIA Portal WinCC Comfort/Advanced with the same syntax.
  3. Time source: The script reads the panel Date, which is set by the panel internal battery-backed RTC. If the plant requires time synchronization to a higher-level clock (NTP, PLC time), use the PLC clock as the source and pass the date to the HMI as a PLC tag, then format the string in the script. This avoids drift between the panel clock and the SCADA clock.
  4. Backup of the project: Store the WinCC flexible source (.hmi or .flex) in the version control system alongside the PLC project. The script is a single text file but is referenced from multiple events (picture Loaded + Scheduler), so a coordinated commit is required to keep them in sync.

FAQ

Why is DD MMM YYYY not in the MP277 Regional Settings dialog?

The MP277 runtime enumerates only the formats defined in the Windows NLS short-date table for the active locale. The en-US, en-GB, and de-DE locales do not include a DD MMM YYYY pattern, so the runtime cannot offer it. A VBScript that rebuilds the string from Day, Month, and Year is the standard workaround.

The date field shows 14-Jul-200 with the 8 truncated. What went wrong?

The internal String tag is sized too small. 14-Jul-2008 is 11 visible characters plus a null terminator; set the tag length to 12 characters (or 16 for safety). The visible field width on the I/O field should be 11 or wider.

How do I avoid the Subscript out of range error at month 12?

Always index the month array with nMonth - 1 because Month() returns 1 for January and 12 for December, while the array is zero-based. The pattern astrMonth(nMonth - 1) is correct.

Can I use this script on a Comfort Panel (TP700 / TP900 / TP1200)?

Yes. The same VBScript pattern, including the month array and the SmartTags write, is supported on TIA Portal WinCC Comfort/Advanced panels. For a WinCC Unified (multi-touch) panel, switch the language from VBScript to JavaScript; the equivalent in Unified is Tags("strCurrentDate").Write(...).

How do I trigger the date update without a Scheduler?

Wire the script to the Loaded event of every picture that displays the date, or to the value-change event of a tag that the PLC updates once per day. The Scheduler is the cleanest approach but is not the only valid option.

Back to blog