How to use constant values and dynamic values in data types?

How to use constant values and dynamic values in data types?

FIRST CREATED ON 17 May 2023  I  AUTHOR Emma Camacho
Depending on the data-type of the constant value (see Constant Values) or dynamic value (see Dynamic Values), you can access certain properties of the value and/or manipulate it.

Date-Time 
More information about all available functions and properties of date-times can be found in the documentation of Microsoft .NET Framework (.NET Framework Documentation on Dates). Generally speaking, the date data type can be accessed using the Date class literal; this class exposes a number of properties and functions.
Current Local Date-Time 
If you want to access the current, local date-time, you can do this by using the following syntax:
Date.Now
Current UTC Date-Time 
If you want to access the current, UTC date-time, you can do this by using the following syntax:
Date.UtcNow
Year, Month, Day, Hour and Minute 
If you just want to use a specific property (e.g. such as the number of the month) of a date, you can use this using one of the following syntaxes:
<Date_Value>.Year
<Date_Value>.Month
<Date_Value>.Day
<Date_Value>.Hour
<Date_Value>.Minute
For example, if you want to access the current year (according to the local date-time), you can use the following syntax:
Date.Now.Year
Calculations 
Visual Basic .NET also offers functionality to perform calculations on dates. 
Adding or Subtracting Days
If you want to add 5 days to the current, local date-time, you can use the following syntax:
Date.Now.AddDays(5)
You can also supply negative values in order to subtract days. 
Adding or Subtracting Months 
If you want to add 5 months to the current, local date-time, you can use the following syntax:
Date.Now.AddMonths(5)
You can also supply negative values in order to subtract months.
Creating a new Date 
You can create a new date (without time) by supplying the individual numeric components for a year, month, and day using the following syntax:
New Date(2018,12,31)
The values supplied do not need to be constant values. You could, for instance, get the date which equals the first day of the next month, by using the following syntax:
New Date(Date.Now.AddMonths(1).Year,Date.Now.AddMonths(1).Month,1)
Creating a new Date-Time 
You can create a new date (including time) by supplying the individual numeric components for a year, month, day, hour, minute and second using the following syntax:
New Date(2018,12,31,18,30,15)
The above expression equals the 31st of December 2018, 6:30 PM and 15 seconds.

Formatting and Conversions 
You can convert a date-time into a text representation by using the ToString function. This conversion process uses the culture settings of the user under which the expression is being executed or another culture provided by the context, e.g. culture-aware reports (see Culture Awareness). If you use the following syntax, the date-time value will be converted to a textual representation using the default format of the applicable culture:
<Date_Value>.ToString()
For instance, if you want to convert the current, local date-time into a textual representation using the default format of the applicable culture, you can use the following syntax:
Date.Now.ToString()
However, the ToString function also allows you to supply a standard format string (Standard Date Time Format Strings Documentation) or a more flexible custom format string (Custom Date Time Format Strings Documentation). For instance, if you want to convert the current, local date-time into a textual representation that contains the 2-digit day, then a dot, then the 2-digit month, then a dot, and then the 4-digit year by using a custom format string, you can use the following syntax:
Date.Now.ToString("dd.MM.yyyy")
If you want to include time-information in the textual representation (a 2-digit hour in 24-hour format, then ":", then a 2-digit minute), then you can use the following syntax:
Date.Now.ToString("dd.MM.yyyy HH:mm")
If you want to convert the current, local date into a textual representation according to the short date pattern of the current culture, you can use the following syntax:
Date.Now.ToString("d")


Info
Looking for Additional Guidance?
If you require more detailed information or further assistance, please visit our comprehensive Online Documentation. Our resources are designed to help you navigate all features and functionalities effectively.


    • Related Articles

    • What are Constant Values in Mail & Deploy and how to use them?

      FIRST CREATED ON 17 May 2023 I AUTHOR Emma Camacho If you want to use a constant, non-calculated value in an expression, you can do this by using the following syntax, which depends on the data type of the constant you want to use. Text. If you want ...
    • What are Dynamic Values and how to use them in Mail & Deploy?

      FIRST CREATED 17 May 2023 I AUTHOR Emma Camacho Expressions are dynamic values - values which are dynamically obtained by the expression at the time of its evaluation. Example: You want to add a text report element to a report and you want the text ...
    • How to do Calculations in Mail & Deploy?

      FIRST CREATED ON 1 May 2020 I AUTHOR Emma Camacho The previously mentioned constant values (see Constant Values) and dynamic values (see Dynamic Values) can not only be used on their own, but they can be used in calculations by using the following ...
    • What are expressions in Mail & Deploy?

      FIRST CREATED ON 17 May 2023 I AUTHOR Emma Camacho In Mail & Deploy, expressions can be used to supply values to certain functions; expressions can either return constant values (see Constant Values), dynamic values (see Dynamic Values) or values ...
    • How to make use of Modules in Mail & Deploy?

      FIRST CREATED ON 17 May 2023 I AUTHOR Emma Camacho You can also write your own Visual Basic .NET code in a module. A module is a set of Visual Basic .NET code that contains functions to be used from any expression within the repository. This allows ...