Bentley Communities
Bentley Communities
  • Site
  • User
  • Site
  • Search
  • User
OpenCities Map
  • Product Communities
  • Geospatial
  • OpenCities Map
  • Cancel
OpenCities Map
OpenCities Map Wiki - Date field settings for use with PBA in SQL Server
    • Sign In
    • -OpenCities Map Wiki
      • -OpenCities Map
        • - End of Support for Bentley Map V8i (SELECTseries) products
        • +Release Information
        • +Installation Information
        • +Getting Started
        • +Administration
        • +General Topics
        • +Geospatial Administrator
        • +Feature Definitions and Inference Rules
        • +Interoperability
        • -Spatial Databases
          • - 3D arcs being stroked when posted and queried
          • - Angle of queried point feature is wrong
          • - Conflict Inspector
          • - Convert DGNs with MSLinks to MS SQL Server Spatial via FME
          • - Create domain lists in Microsoft SQL Server Spatial or Oracle
          • - Create XFM DGN file using Import from database
          • - Creating a Map schema for spatial features
          • - Creating Oracle Spatial multi-table views
          • - Creating Oracle Spatial Views
          • - Data streaming
          • - Data streaming and the Data Browser
          • - Date field settings for use with PBA in SQL Server
          • - Determine which features are locked and modified
          • - Difference between Erase and Delete for removing spatial database features
          • - Disable Connect to Database dialog
          • - Esri File Geodatabase as a Graphical Source
          • - Establish database connection upon startup
          • - Item names showing __x00##__
          • - Keep connection to database open when changing files
          • - Key-ins for interacting with spatial databases
          • - Key-ins to created queries incorporating a simple WHERE
          • - Long transactions - Versioned optimistic transactions
          • - Non planar polygon posting error ORA-54505
          • - Oracle views in spatial feature definitions
          • - Plane Constraint settings
          • - Register features times out with error
          • - Saving connection parameters to settings file
          • - SQL Server Features Not Displaying in Bentley Map
          • - Supported OGC geometry types
          • - Using joins to create custom searches
          • - WFS graphical source connection and feature registration
          • - Connecting to ArcGIS Server
        • +Spatial Analysis
        • +3D Geospatial
        • +Geographic Coordinate Systems
        • +Troubleshooting
        • +Freeware - Utilities - Applications - Programs
        • +Advanced Map Finishing
      • OpenCities Map Ultimate for Finland CONNECT Edition x64 (SES)
      • OpenCities Map Ultimate for Finland CONNECT Edition - Suomi
      • Bentley Descartes
      • +Other Geospatial Products

     
     Questions about this article, topic, or product? Click here. 

    - Date field settings for use with PBA in SQL Server

    PBA text replacement for SQL Server dates

    The following discusses how to replace date fields in queried SQL Server features that are being placed as a cell.

    Play this video

    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:


    Format

    Description

    d

    The one- or two-digit day.

    dd

    The two-digit day. Single-digit day values are preceded by a 0.

    ddd

    The three-character day-of-week abbreviation.

    dddd

    The full day-of-week name.

    h

    The one- or two-digit hour in 12-hour format.

    hh

    The two-digit hour in 12-hour format. Single digit values are preceded by a 0.

    H

    The one- or two-digit hour in 24-hour format.

    HH

    The two-digit hour in 24-hour format. Single digit values are preceded by a 0.

    m

    The one- or two-digit minute.

    mm

    The two-digit minute. Single digit values are preceded by a 0.

    M

    The one- or two-digit month number.

    MM

    The two-digit month number. Single digit values are preceded by a 0.

    MMM

    The three-character month abbreviation.

    MMMM

    The full month name.

    s

    The one- or two-digit seconds.

    ss

    The two-digit seconds. Single digit values are preceded by a 0.

    t

    The one-letter A.M./P.M. abbreviation (A.M. is displayed as “A”).

    tt

    The two-letter A.M./P.M. abbreviation (A.M. is displayed as “AM”).

    y

    The one-digit year (2001 is displayed as “1”).

    yy

    The last two digits of the year (2001 is displayed as “01”).

    yyyy

    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

    • OpenCities Map
    • PBA
    • DateTimeTicks
    • Replacement Text
    • Geospatial Administrator
    • Date Field
    • schema
    • GSA
    • Share
    • History
    • More
    • Cancel
    • Dan Weston Created by Bentley Colleague Dan Weston
    • When: Thu, Jan 19 2017 5:45 PM
    • Dan Weston Last revision by Bentley Colleague Dan Weston
    • When: Thu, Dec 10 2020 4:11 PM
    • Revisions: 8
    • Comments: 0
    Recommended
    Related
    Communities
    • Home
    • Getting Started
    • Community Central
    • Products
    • Support
    • Secure File Upload
    • Feedback
    Support and Services
    • Home
    • Product Support
    • Downloads
    • Subscription Services Portal
    Training and Learning
    • Home
    • About Bentley Institute
    • My Learning History
    • Reference Books
    Social Media
    •    LinkedIn
    •    Facebook
    •    Twitter
    •    YouTube
    •    RSS Feed
    •    Email

    © 2023 Bentley Systems, Incorporated  |  Contact Us  |  Privacy |  Terms of Use  |  Cookies