Skip to main content
Question

Formatting the resulting interval (ISO Duration)

  • April 23, 2020
  • 10 replies
  • 158 views

itay
Supporter
Forum|alt.badge.img+18
  • Supporter
  • 1442 replies

Hi,

I am currently calculating date time intervals via the DateTimeCalculator that result is ISO Duration format (PT28M20S for example)

I would like to format the result into a FME datetime but havent found a way to do it with the DateTimeConverter. I can split the value into its parts and then combine them but there should be an easier way...

I am surprised that FME doesn't recognize and can parse this date time notation, after all FME is producing it....

Using FME 2019.2.0.0 build 19801

Could be I am missing something, any assistance would be appreciated.

Cheers,

Itay

This post is closed to further activity.
It may be an old question, an answered question, an implemented idea, or a notification-only post.
Please check post dates before relying on any information in a question or answer.
For follow-up or related questions, please post a new question or idea.
If there is a genuine update to be made, please contact us and request that the post is reopened.

10 replies

ebygomm
Influencer
Forum|alt.badge.img+44
  • Influencer
  • 3427 replies
  • April 23, 2020

PT28M20S is a duration of 28 minutes and 20 seconds, it can't be converted to an FME datetime. Or do you mean you want to add it onto a known date time?


itay
Supporter
Forum|alt.badge.img+18
  • Author
  • Supporter
  • 1442 replies
  • April 23, 2020

PT28M20S is a duration of 28 minutes and 20 seconds, it can't be converted to an FME datetime. Or do you mean you want to add it onto a known date time?

Hi @ebygomm,

No I want to format it into a FME datetime, so that I can eventually write it out as a datetime.

So I guess it's gonna be 'the hard way'....padding, etc


ebygomm
Influencer
Forum|alt.badge.img+44
  • Influencer
  • 3427 replies
  • April 23, 2020

Hi @ebygomm,

No I want to format it into a FME datetime, so that I can eventually write it out as a datetime.

So I guess it's gonna be 'the hard way'....padding, etc

But it's not a date time it's a duration - what datetime would you expect PT28M20S to become?


itay
Supporter
Forum|alt.badge.img+18
  • Author
  • Supporter
  • 1442 replies
  • April 23, 2020

PT28M20S is a duration of 28 minutes and 20 seconds, it can't be converted to an FME datetime. Or do you mean you want to add it onto a known date time?

True, I need to write it into an oracle date time data type.


Forum|alt.badge.img+2
  • 1891 replies
  • April 23, 2020

@itay Oracle and other databases do have Interval date types. This isn't something we have tackled in FME yet so you'll have to parse the FME Duration for now. Also, I don't think the FME feature types support the 'interval' data types so you'll have to create the table before you write to it.


itay
Supporter
Forum|alt.badge.img+18
  • Author
  • Supporter
  • 1442 replies
  • April 23, 2020

@itay Oracle and other databases do have Interval date types. This isn't something we have tackled in FME yet so you'll have to parse the FME Duration for now. Also, I don't think the FME feature types support the 'interval' data types so you'll have to create the table before you write to it.

Thx for the info @markatsafe, luckily the table already exists.


ebygomm
Influencer
Forum|alt.badge.img+44
  • Influencer
  • 3427 replies
  • April 23, 2020

Thx for the info @markatsafe, luckily the table already exists.

If you're actually wanting to write to an interval date type column if you want to avoid parsing the date time interval you can create a dummy date which contains the interval added onto an arbitrary date

and write that into a temporary table. Then populate the interval column with a query by taking the arbitrary date away from the dummy date.

FME doesn't play nicely with columns of interval date types (unless this has changed in 2020) so that's something to be aware of. You cannot 'see' the interval columns with the reader, you can read with sqlcreator/sqlexecutor if you convert them (and know they're there and their names)


warrendev
Enthusiast
Forum|alt.badge.img+26
  • Enthusiast
  • 121 replies
  • April 23, 2020

Hi @ebygomm,

No I want to format it into a FME datetime, so that I can eventually write it out as a datetime.

So I guess it's gonna be 'the hard way'....padding, etc

You could probably do some string manipulation, but there is also an easy to use python library isodate that will do it for you.

 

pip install isodate

 

import isodate 
duration = 'PT28M20S'
print(isodate.parse_duration(duration))

Result

0:28:20

itay
Supporter
Forum|alt.badge.img+18
  • Author
  • Supporter
  • 1442 replies
  • April 23, 2020

You could probably do some string manipulation, but there is also an easy to use python library isodate that will do it for you.

 

pip install isodate

 

import isodate 
duration = 'PT28M20S'
print(isodate.parse_duration(duration))

Result

0:28:20

Hi @warrengis, that does look interesting...

thx for the tip.


itay
Supporter
Forum|alt.badge.img+18
  • Author
  • Supporter
  • 1442 replies
  • April 23, 2020

If you're actually wanting to write to an interval date type column if you want to avoid parsing the date time interval you can create a dummy date which contains the interval added onto an arbitrary date

and write that into a temporary table. Then populate the interval column with a query by taking the arbitrary date away from the dummy date.

FME doesn't play nicely with columns of interval date types (unless this has changed in 2020) so that's something to be aware of. You cannot 'see' the interval columns with the reader, you can read with sqlcreator/sqlexecutor if you convert them (and know they're there and their names)

that is a very interesting approach, thx for the tip.