Designers > K2 Designer for Visual Studio > Design Tools > Inline Functions > Function Browser > Date and Time | Send feedback |
Date and Time functions perform operations on date and time input values and returns a string, numeric, or date and time value.
Fig. 1. Date and Time
An item is selected and then added to the canvas or K2 field part by clicking the Add button or by using drag-and-drop.
Functions | Description | Example |
---|---|---|
Add Days | Adds a specified number of days to a date. | Date and Time: 01/01/2009 00:00:00 AM Days: 1 Result: 01/02/2009 00:00:00 AM |
Add Hours | Adds a specified number of hours to a date and time. | Date and Time: 01/01/2009 00:00:00 AM Hours: 1 Result: 01/01/2009 01:00:00 AM |
Add Minutes | Adds a specified number of minutes to a date and time. | Date and Time: 01/01/2009 00:00:00 AM Minutes: 1 Result: 01/01/2009 00:01:00 AM |
Add Seconds | Adds a specified number of seconds to a date and time. | Date and Time: 01/01/2009 00:00:00 AM Seconds: 1 Result: 01/01/2009 00:00:01 AM |
Day | Gets the day of a given date. | Date: 01/01/2009 00:00:00 AM Result: 1 |
Day Difference | Determines the number of days between two dates, and hours are decimal fractions. |
Example 1: Example 2: |
End of Month - Integer | Gets the last day of a month. | Year: 2009 Month: 1 Result: 01/31/2009 11:59:59 PM |
End of Month - DateTime | Gets the last day of a month. | Date and Time: 01/01/2009 00:00:00 AM Result: 01/31/2009 11:59:59 PM |
End of Quarter - Integer | Gets the last day of a quarter. |
Year: 2009 Result: 03/31/2009 11:59:59 PM |
End of Quarter - DateTime | Gets the last day of a quarter. | Date and Time: 01/01/2009 00:00:00 AM Result: 03/31/2009 11:59:59 PM |
End of Week - Integer | Gets the last day of a week. | Year: 2009 Week: 1 Result: 01/06/2009 11:59:59 PM |
End of Week - DateTime | Gets the last day of a week. | Date and Time: 01/01/2009 00:00:00 AM Result: 01/06/2009 11:59:59 PM |
End of Year - DateTime | Gets the last day of a year. | Date and Time: 01/01/2009 00:00:00 AM Result: 12/31/2009 11:59:59 PM |
End of Year - Integer | Gets the last day of a year. | Year: 2009 Result: 12/31/2009 11:59:59 PM |
Format Date and Time | Formats a date and time to a text representation using a specified date and time format. | DateTime: 01/01/2009 00:00:00 AM Format: "dddd, dd MMMM yyyy" Result: "Thursday, 1 January 2009" |
Maximum | Gets the maximum date and time from a list of values. |
Values: {01/01/2009 00:00:00 AM, 01/02/2009 00:00:00 AM }
Result: 01/02/2009 00:00:00 AM |
Minimum | Gets the minimum date and time from a list of values. |
Values: {01/01/2009 00:00:00 AM, 01/02/2009 00:00:00 AM }
Result: 01/01/2009 00:00:00 AM |
Month | Gets the month of a given date as a number. | Date: 01/01/2009 00:00:00 AM Result: 1 |
Now | Gets the current date and time. | Result: 05/20/2009 03:34:27 PM |
Quarter | Gets the quarter number a specified date is in. | Date and Time: 01/01/2009 00:00:00 AM Result: 1 |
Start of Month - DateTime | Gets the first day of a month. | Date and Time: 01/01/2009 00:00:00 AM Result: 01/01/2009 00:00:00 AM |
Start of Month - Integer | Gets the first day of a month. | Year: 2009 Month: 1 Result: 01/01/2009 00:00:00 AM |
Start of Quarter - DateTime | Gets the first day of a quarter. | Date and Time: 01/01/2009 00:00:00 AM Result: 01/01/2009 00:00:00 AM |
Start of Quarter - Integer | Gets the first day of a quarter. | Year: 2009 Quarter: 1 Result: 01/01/2009 00:00:00 AM |
Start of Week - Integer | Gets the first day of a week. | Year: 2009 Week: 1 Result: 12/28/2008 00:00:00 AM |
Start of Week - DateTime | Gets the first day of a week. | Date and Time: 01/01/2009 00:00:00 AM Result: 12/28/2008 00:00:00 AM |
Start of Year - Integer | Gets the first day of a year. | Date and Time: 01/01/2009 00:00:00 AM Result: 01/01/2009 00:00:00 AM |
Start of Year - DateTime | Gets the first day of a year. | Year: 2009 Result: 01/01/2009 00:00:00 AM |
Subtract Days | Subtracts a specified amount of days from a date. | Date and Time: 01/01/2009 00:00:00 AM Days: 1 Result: 12/31/2008 00:00:00 AM |
Subtract Hours | Subtracts a specified amount of hours from a date and time. | Date and Time: 01/01/2009 00:00:00 AM Hours: 1 Result: 12/31/2008 00:23:00 AM |
Subtract Minutes | Subtracts a specified amount of minutes from a date and time. | Date and Time: 01/01/2009 00:00:00 AM Minutes: 1 Result: 12/31/2008 00:59:00 AM |
Subtract Seconds | Subtracts a specified number of seconds from a date and time. | Date and Time: 01/01/2009 00:00:00 AM Seconds: 1 Result: 12/31/2008 00:00:59 AM |
Today | Gets the current day. | Result: 05/20/2009 00:00:00 AM |
Tomorrow | Return tomorrow's date. | Result: 05/21/2009 00:00:00 AM |
Week Number | Gets the week number of the year of a specified date. | Date: 01/01/2009 00:00:00 AM Result: 6 |
Weekday | Gets the name of the day of the week from a specified date. | Date: 01/01/2009 00:00:00 AM Result: "Thursday" |
Year | Gets the year of a date. | Date: 01/01/2009 00:00:00 AM Result: 2009 |
Yesterday | Returns yesterday's date. | Result: 05/19/2009 00:00:00 AM |
The following table lists the date and time abbreviations recognized by the Format Date and Time function.
Date and Time | Abbreviations | Example |
---|---|---|
Year | y, yy, yyyy | 9, 09, 2009 |
Month | M, MM, MMM, MMMM | 2, 02, Feb, February |
Day | d, ddd, dddd | 21, Sat, Saturday |
Hour | h, hh, H, HH | 4, 04, 16, 16 |
Minute | m, mm | 1, 01 |
Second | s, ss | 1, 01 |
Millisecond | ffff | 9999 |
A.M. or P.M. | t, tt | P, PM |
Timezone | z, zz, zzz | -6, -06, -06:00 |
The following table lists the standard date and time specifiers recognized by the Format Date and Time function.
Specifier | Pattern value (for en-US culture) |
---|---|
t | h:mm tt |
d | M/d/yyyy |
T | h:mm:ss tt |
D | dddd, MMMM dd, yyyy |
f | dddd, MMMM dd, yyyy h:mm tt |
F | dddd, MMMM dd, yyyy h:mm:ss tt |
g | M/d/yyyy h:mm tt |
G | M/d/yyyy h:mm:ss tt |
m, M | MMMM dd |
y, Y | MMMM, yyyy |
r, R | ddd, dd MMM yyyy HH':'mm':'ss 'GMT' (*) |
s | yyyy'-'MM'-'dd'T'HH':'mm':'ss (*) |
u | yyyy'-'MM'-'dd HH':'mm':'ss'Z' (*) |
(*) = culture independent |
The Function Wizard content varies according to the selected function: