Home
About
Search
Welcome to M-Files Empower – our new support experience. We'd love to hear what you think!Give feedback
Home

Add Date to a Text Property with Chosen Format (VBscript) in M-Files

Last updated on 27 December 2023 · 2 min read

COM API

Overview

NOTE: If you are concatenating Date, Time, or Timestamp type properties to form another property value, you can affect the format of the properties in the end result by modifying the Advanced Vault Setting: Configuration > Properties > Format for Calculated Dates and Times.
Please notice that scripting is not part of standard support and this is just an example script to show how to use the API.

Related article for date formats:
Support article: Date Format Problem with Concatenated property
Sometimes it is not possible to change the settings mentioned in the article, but you might still want to use the date in a chosen format for example in an automatic name for a document.
 

Solution

You can use VBscript date/time functions to manipulate date format.
https://www.w3schools.com/asp/asp_ref_vbscript_functions.asp

Here is a sample code for outputting an automatic value for a text type property. This property can then be utilized when for example concatenating automatic names.
It retrieves the date property (ID 1076) and uses the date/time functions to rearrange it.
NOTE: This script is only a sample. Production scripts should use aliases for identifying property values.

Option Explicit

Const iPDDate = 1076
Dim dDate : dDate = PropertyValues.SearchForProperty(iPDDate).TypedValue.Value

Dim szYear : szYear = DatePart("yyyy",dDate)
Dim szMonth : szMonth = DatePart("m",dDate)
Dim szDay : szDay = DatePart("d",dDate)

Output = szDay & "." & szMonth & "." & szYear

 

 

Still need help?

On this page