DateTimeCalculator
Performs arithmetic on date, time, datetime, and interval values.In Advanced Expression mode, composite expressions involving datetimes and intervals may be constructed.
也可以看看:日期/Time Terminology,日期/Time Format,日期/Time Functions
DateTimeCalculator在五个上执行算术temporal types:
- 日期
- Time
- Time with UTC offset
- 约会时间
- 与UTC偏移量的DateTime
输入的时态字符串必须在FME format.
If input strings are invalid but repairable, they will be auto repaired. For example, in a date string, month = 13 will cause the year to be incremented by 1, and month set to 01.
DateTimeCalculatoralso supports interval arithmetic, where the interval can be specified in one of two ways:
- Specified by part. For example, the user can specify 5 for the value of “Years”.
- Specified by an interval string inISO 8601 duration format.
Invalid temporal and interval input will cause date time functions that consume them to return null, and cause the feature to be rejected.
Limitations:
- Supported temporal range: 1000-01-01 00:00:00.000000000 to 9999-12-31 23:59:59.999999999.
- 如果输入时间值包含分数秒,则只有十进制分隔符“。”。得到支持。
- When subtracting a temporal value from another, the two temporal values must have the same temporal type, or the feature will be rejected.
- 如果零件指定了间隔,则零件值必须是所有非负,或者所有非正数,或者将被拒绝。
输入端口
![关闭](http://www.baooytra.com/docs/fme/2017.0/html/FME_Desktop_Documentation/FME_Transformers/Transformers/../Skins/Default/Stylesheets/Images/transparent.gif)
Accepts and processes features one by one. Temporal values and interval values can come from attributes.
输出端口
![关闭](http://www.baooytra.com/docs/fme/2017.0/html/FME_Desktop_Documentation/FME_Transformers/Transformers/../Skins/Default/Stylesheets/Images/transparent.gif)
Outputs valid results.
![关闭](http://www.baooytra.com/docs/fme/2017.0/html/FME_Desktop_Documentation/FME_Transformers/Transformers/../Skins/Default/Stylesheets/Images/transparent.gif)
Outputs invalid results, which are set to null. When features come out of this port, please check if the input strings are valid syntactically, and then if they are valid semantically.
Parameters
![关闭](http://www.baooytra.com/docs/fme/2017.0/html/FME_Desktop_Documentation/FME_Transformers/Transformers/../Skins/Default/Stylesheets/Images/transparent.gif)
Specifies the operation to perform:
- 添加或减去间隔:添加一个区间或从颞颥减去它l value. The interval is specified by part. That is, by years, months, days, hours, minutes, and fractional seconds. Only seconds are allowed to be fractional. The other parts are integers. The parts must be all non-negative or all non-positive, otherwise the feature is rejected. The result has the same temporal type as the input temporal type.
- 添加或减去间隔(ISO Duration):添加一个区间或从颞颥减去它l value. The interval is specified inISO 8601 duration格式。结果具有与输入时间类型相同的时间类型。
- 计算日期时间之间的间隔: end time minus start time produces an interval. The user can choose to output the interval inISO 8601 duration格式,或分数年,月,周,天,小时,分钟或秒。
- Advanced Expression: datetime functions can be used to construct composite expressions such as @DateTimeAdd(time1, @DateTimeDiff(@Value(time2) – @Value(time3)).
![关闭](http://www.baooytra.com/docs/fme/2017.0/html/FME_Desktop_Documentation/FME_Transformers/Transformers/../Skins/Default/Stylesheets/Images/transparent.gif)
指定起始时间值。选择是加还是减间隔。然后,为感兴趣的间隔部分指定值。支持的间隔部分包括年、月、日、小时、分钟和秒。seconds参数可以是小数。其他部分值必须是整数。
注意:Float values for integer-only fields are rounded into integers.
![关闭](http://www.baooytra.com/docs/fme/2017.0/html/FME_Desktop_Documentation/FME_Transformers/Transformers/../Skins/Default/Stylesheets/Images/transparent.gif)
指定启动时间值。选择是否添加或减去间隔。然后,指定间隔ISO 8601 duration格式。
![关闭](http://www.baooytra.com/docs/fme/2017.0/html/FME_Desktop_Documentation/FME_Transformers/Transformers/../Skins/Default/Stylesheets/Images/transparent.gif)
Specify start and end temporal values. Then, pick the output interval type. Supported interval types are:
- ISO 8601 duration格式。
- Fractional years, which is calculated as the number of fractional months divided by 12.
- 小数月:开始和结束日期之间有一些满月。剩余时间不是全月的时间包括多天,小时,分钟和秒。其余的始于一个月被称为“余数月”。其余部分首先转化为小数天。然后,小数日由剩余月份的天数除以。其余的月份是刚刚(并含有一部分或全部)剩余部分,并保证其余时间从未大于一个月,当表达为少数月。最后,剩下的时间作为少数月的数月增加,给我们产生的小月份。
- Example, from 2016-Jan-01 (start) to 2017-Mar-31 (end) there is 1 year and 2 months plus a remainder. 2016-Jan-01 + 1 year + 2 months takes us to 2017-Mar-01, which means that the remainder month is 2017-Mar. That month has 31 days. So, the remainder of 30 days, is divided by 31 to get the fractional month. The total number of months between the two dates are therefore 1 year (12 months) + 2 months + 30/31 months = 14.967742.
- 几周,天,小时,分钟,秒:对于所有这些,我们首先在分数秒时计算开始和结束日期时间之间的持续时间。转换然后发生在指定的单位上。一分钟内有60秒。每小时60分钟,一天24小时,一周7天。
注意:To re-use fractional years, months, weeks, days, hours, or minutes in a DateTimeCalculator or@DateTimeAdd(), please round or truncate the fractional values into integers first.
Tip:Fractional years, months, weeks, days, hours, minutes, or seconds as the output interval type may be useful for comparison and reporting.
![关闭](http://www.baooytra.com/docs/fme/2017.0/html/FME_Desktop_Documentation/FME_Transformers/Transformers/../Skins/Default/Stylesheets/Images/transparent.gif)
Construct composite FME expressions involving datetime, for example:
- @DateTimeAdd(@Value(newStartDate),@DateTimeDiff(@Value(projEnd),@Value(projStart))
- @datetimecast(@datetimenow(),时间)
- @DateTimeFormat(@DateTimeParse(@Value(sourceString),@Value(inputFormat)),@Value(outputFormat))
请看FME日期/时间函数.
Editing Transformer Parameters
使用一组菜单选项,可以通过引用工作区中的其他元素来分配变压器参数。一些变压器也可提供更高级的功能,例如高级编辑器和算术编辑器。要访问这些选项的菜单,请单击除适用的参数旁边。有关更多信息,请参阅Transformer Parameter Menu Options.
Transformer Categories
Search FME Knowledge Center
Search for samples and information about this transformer on theFME Knowledge Center.