The following discusses how to replace date fields in queried SQL Server features that are being placed as a cell.
A cell is created and specified in the Symbology tab of the Symbology node. In this example, the text values [DATE_ADDED] and [DATE_EDITED] are used as placeholders for the database date properties.
Note: There is no formatting associated with date fields in SQL Server. The display of the date is controlled by the application getting the dates from the database.
When SQL Server features are registered, date properties are set as follows:
For the Date_Edited property, an Editing key was added and set to dateTimeTicks. This enables OpenCities Map to extract the current date and apply it to this field when the feature is edited.
The display format can be changed to any number of valid formats as described in the following table:
The one- or two-digit day.
The two-digit day. Single-digit day values are preceded by a 0.
The three-character day-of-week abbreviation.
The full day-of-week name.
The one- or two-digit hour in 12-hour format.
The two-digit hour in 12-hour format. Single digit values are preceded by a 0.
The one- or two-digit hour in 24-hour format.
The two-digit hour in 24-hour format. Single digit values are preceded by a 0.
The one- or two-digit minute.
The two-digit minute. Single digit values are preceded by a 0.
The one- or two-digit month number.
The two-digit month number. Single digit values are preceded by a 0.
The three-character month abbreviation.
The full month name.
The one- or two-digit seconds.
The two-digit seconds. Single digit values are preceded by a 0.
The one-letter A.M./P.M. abbreviation (A.M. is displayed as “A”).
The two-letter A.M./P.M. abbreviation (A.M. is displayed as “AM”).
The one-digit year (2001 is displayed as “1”).
The last two digits of the year (2001 is displayed as “01”).
The full year (2001 is displayed as “2001”).
When defining text replacement, you may find yourself inserting Simple Replacement Text for date properties. This will result in date ticks being used rather than properly formatted date fields.
To overcome this, select PBA Replacement Text instead of a Simple Replacement Text.
The Value field can be any text string and is used to identify the replacement text. In this example, Date_Added and Date_Edited are used.
In the Details section, the Old Text is defined as the text to replace. In this example, its [DATE_ADDED] and [DATE_EDITED] in the cell that will be placed during the query process.
Details for Date_Added property:
Details for Date_Edited property:
When the replacement text has been defined, the associated PBA needs to be created.
This is done by highlighting the Replacement Text key and selecting Insert > PBA (Expression) from the right click menu.
A new PBA key is inserted above the Replacement Text. The value of the PBA key is edited from the default [Expression] to the name of the feature property being replaced. Note that the property name must be enclosed in square brackets as shown:
Finally, in the PBA Details, change the default Name New to the value of the Replacement Text key. In this example, it’s Date_Added and Date_Edited. The Type value will remain as a PBA Expression.
Date Added PBA Details:
Date Edited PBA Details:
When placing new features, the Date Added and Date Edited fields are automatically set to the current date:
However, they can be set manually as well:
Finally, when queried features are edited, the Date Edited field will automatically update to capture the current date:
PDF Download the PDF
SQL Server Date.zip
Attached is the project schema which you can use for learning.
- modified the Wiki category, 07/06/2019