Designers > K2 Designer for Visual Studio > Design Tools > Inline Functions > Function Browser > Expression > Build Expression > Literals | Send feedback |
Literal | Description | Example |
---|---|---|
text | Used to create a text value. Start with either " or ' and end the literal with the same character. |
Input Value: "Hello ""Customer""" |
integer | Used to create an integral value. | Input Value: 1 Result: 1 |
decimal | Used to create a real (decimal) value. | Input Value: 1.0 Result: 1.0 |
boolean | Used to create a Boolean value, “yes” or “true”; and “no” or “false”. | Input Value: yes Result: true |
date time | Used to create a date time value. It must be one of the following: [year month day] [year month day hour:minute] [year month day hour:minute:second] |
Input Value: [2001 01 01] Result: First January 2001 Input Value: [1001*2 01 01] Result: First January 2002 |
time span | Used to create a time span. It must be one of the following: [hours:minutes:seconds] [days:hours:minutes:seconds] [days:hours:minutes:seconds:milliseconds] |
Input Value: [15:0:0] Result: 15 hours Input Value: [8*2:0:0:0] Result: 16 days |
Numbers can either be integers or decimals; for example, 5 and 5.1. Remember even 5.0 is a decimal. Exception: When working with mathematical or comparison operators it is valid (unlike functions) to use text. For instance the following is perfectly valid:
However, if the operator is not mathematical two strings will be left as strings:
However if one is a number both will be numbers:
Finally, these string values are NOT validated – they will only fail at runtime. Validation in this case has been relaxed to make it simpler to use Field Parts that do not have the correct type.
Strings are pieces of text. They can start with either a double quote " or a single quote '; they must start and end with the same type of quote. They can contain new lines. To add a quote in the middle of a string, double it up. For instance:
"Dear Customer,
We would like to thank you for the purchase of ""Product"".
Regards
Management"
Or:
'Dear Customer,
We would like to thank you for the purchase of ''Product''.
Management'
Adding a Field Part in the middle of the string can be done in the following way: "Dear " + [Customer] + ","
Valid values for Boolean literals are true and false, as well as yes and no.
Dates can be specified in an expression using the following syntax:
Copy |
---|
[yyyy mm dd] Or [yyyy mm dd hh:mm] Or [yyyy mm dd hh:mm:ss] |
Date and time span literals can also contain operators or Field Parts in their terms, as long as they evaluate to positive integer values. For example the following expression is valid:
Copy |
---|
[(1002 * 2) 01 01] |
Subtraction:
Two dates can also be subtracted, whether Field Part or date literal. This will result in a time span.
You can also specify time differences in an expression. Please note that a TimeSpan cannot be the result of an expression because K2 does not support it outside of the expression builder – it must be used to form a date.
Copy |
---|
[hh:mm:ss] Or [dd:hh:mm:ss] Or [dd:hh:mm:ss:ms] |
Timespan behave the same as date literals – you can use operators inside of terms. The following expression will result in a valid Timespan:
Copy |
---|
[1+1:00:00] |
Please note that both the date and Timespan literals have no concept of localization. |
Addition:
You can add two time spans (results in a Timespan). You can also add a Timespan to a DateTime which results in a DateTime. Example:
Copy |
---|
[2010 01 01] + [01:00:00:00] = [2010 01 02] |
Subtraction:
You can subtract two TimeSpans (results in a TimeSpan). This will give you the difference between them. Example:
Copy |
---|
[03:00:00:00]- [02:00:00:00] = [01:00:00:00] |
As previously stated, this cannot be the final result of an expression and must be used as part of a bigger expression that involves dates. |
Negation:
This will make the TimeSpan negative (results in a TimeSpan).