Date, Time, Time Add and Subtract, and Time Conversion Blocks
These are the various date and time related blocks available in the Time group of the block library:
- date: extracts just the date portion of a date time value
- dateTimeAdd: adds a duration (hrs, mins, or secs) to a dateTime
- dateTimeSub: subtracts a duration (hrs, mins, or secs) from a dateTime
- dateToNumber: converts the date into a number
- dateToString: converts a part of date into a string
- dtToDtAdd: adds one dateTime to another dateTime; results in a duration of minutes or seconds
- dtToDtSub: subtracts one dateTime from another dateTime; results in a duration of minutes or seconds
- now: gets the current dateTime for the host
- siteDateTime: gets the current date and time for the site associated with the target Ref of the bline program
- time: extracts just the time portion of a date time value
- timeToMinutes: converts a time value to a number of minutes
- timeToTimeAdd: adds one time to another time; results in a duration of minutes or seconds
- timeToTimeSub: subracts one time from another time; results in a duration of minutes or seconds
Some blocks have inputs or results in dateTime format, while others in simple time format. Blocks that require a time format input might not work if a dateTime value is used as the input.
dateTime example: 2019-07-04 14:39:15:149 (date and time with milliseconds)
time example: 14:39:15 (just hours:minutes:seconds)
The Blocks can be found in the Block Library in the Time group.
Date and Time Blocks
These four blocks provide or extract a value of time or dateTime, depending on your usage and need.
date: extracts just the date portion of a date time value
time: extracts just the time portion of a date time value
now: gets the current date and time from the host PC where the program is running
siteDateTime: gets the current date and time for the site associated with the target Ref of the bline program
Time Add and Subtract Blocks
dateTimeAdd: adds a duration (days, hrs, mins, or secs) to a dateTime
dateTimeSub: subtracts a duration (days, hrs, mins, or secs) from a dateTime
dtToDtAdd: adds one dateTime to another dateTime; results in a duration of minutes or seconds. Note: This is not to be considered a traditional add function. Rather, the result is in fact an invert of a subtraction of the two inputs. Meaning, if the difference is 30 minutes, then the result is written as -30 min. So it is actually subtracting the two inputs and then inverting the math sign of the result.
dtToDtSub: subtracts one dateTime from another dateTime; results in a duration of minutes or seconds
timeToTimeAdd: adds one time to another time; results in a duration of minutes or seconds. Note: This is not to be considered a traditional add function. Rather, the result is in fact an invert of a subtraction of the two inputs. Meaning, if the difference is 30 minutes, then the result is written as -30 min. So it is actually subtracting the two inputs and then inverting the math sign of the result.
timeToTimeSub: subracts one time from another time; results in a duration of minutes or seconds
Time Conversion Blocks
dateToNumber: converts the date into a number. This block extracts a selected portion of the date and converts it to a number that represents that Year, Month, Day, etc.
As you can see in the example below, we show how to use the block to extract those three entities from the date. You could also get Hour, Minute, or Second if desired.
dateToString: converts a part of date into a string
timeToMinutes: converts a time value to a number of minutes
The above screenshot represents several examples of the date/time block usage.
- a tag will get the date and time value from the site associated with the target Ref of the program
- another tag will get only the time value from a date & time tag(the one create at the first step)
- then using the dateToString block the value only for the weekday and month are picked from the same time
- finally using the dateToNumber block there are several numbers collected from the same tag for
Click on the link below to watch a video demonstration on how the above example was set up!