A23. What is the Best Way to Add a Date in a Template?

 

There are several ways to add a date in your templates. This entry will show you three options and their differences. If you're not familiar with templates, we advise you to watch the tutorials first.

Option 1: Add a Date Field

You can easily add a 4D date field in your template. You can select the format in the dialog box:

This option is not advisable if you're using templates in other languages. The database will only display the date in the language of your operating system.

 

Option 2: Use “UTI_GetLetterDate”

You can use the feature "UTI_GetLetterDate", which lets you define the language in order to display the date in the template's language (the month is written out). Using one variable only will display the current date. The second optional variable can display a database field. For example, this lets you print the invoice's date in the desired language.

Option 3: Use ”GEN_INSERT”

The command "GEN_INSERT" lets you add date and place. The first variable indicates which date to use: "letterdate" uses the date of the database record (e.g. the invoice), "currentdate" uses the current date. The second variable lets you add a language code, that is e.g. "de", "fr", "en", etc.

Comparison chart

The following chart shows the different options and the results, using a template in its English-language version.