How do I change the date format used in Text Substitution to reflect MM/dd/yy?


Product(s):MicroStation
Version(s):N\A
Environment:N\A
Area:N/A
Subarea:N\A

Problem Description

How do I change the date format used in Text Substitution to reflect MM/dd/yy?

Steps to Resolve

I have two suggestions to obtain the desired format:

1. In Windows set the "Short date:" to "MM/dd/yy" under (Windows 10) Control Panel->Language, Select "Change date, time, or number format", select the "Format" tab, (Windows 7) Control Panel->Region and Language, select the "Format" tab. Make sure to restart MicroStation. By changing this option it affects any other application that uses the "Short date" format.

2. Create a Named Expression and use the same in the Replacement field of the Text Substitution

I will suggest you keep your named expressions in the same .dgnlib where you keep your print styles.

Open your .dgnlib
In the MicroStation pulldown menus select Utilities->Named Expressions
Click on the New Icon
Enter a name under the "Internal Name" and "External Names" fields. In this example I will use _DateOnly for both fields
Under "Keywords" select File
Under "Symbol Sets", add System.string and System.DateTime
Under Expression enter
System.String.Format ("{0:MM/dd/yy}", System.DateTime.Now())

Verify what your replacement string will look like by clicking on Test

Now edit your pen table and edit the entry you have for the date.
In the Replacement field enter:
<expr?name=_dateonly>
if the name of the fields are different use "Internal Name"
Save your pen table, your results should reflect the desired results in the date format

You can access Help on Named Expressions by entering "Named Expressions Dialog" under Search in MicroStation

See Also

https://communities.bentley.com/products/microstation/microstation_printing/w/wiki/13575/how-to-get-date-and-time-stamp-to-plot-using-a-single-microstation-pen-table-text-substitution-variable