Skip to main content
Question

DATETIME CALCULATION FOR MINUTES


fme
Contributor
Forum|alt.badge.img+7

Q1. I need help adding 15mins to the this datetime:

5/10/2023 06:45 PM

 

Q2. I also want to be able to pick two datetime points to calculate the duration in hours.

Eg. (a) 5/10/2023 07:00 PM (b) 5/10/2023 12:00 AM

 

Tried several options but can't get it to work. Thanks!

8 replies

j.botterill
Evangelist
Forum|alt.badge.img+69

Hi there,

In terms of Q1, you may need to use a DateTimeConverter first, format the input using the quick reference syntax as per following example

datetimeConverterThen use a DateTimeCalculator to add the 15minutes.

dateTimeCalculatorI'll let you calculate Q2 using the above steps


fme
Contributor
Forum|alt.badge.img+7
  • Author
  • Contributor
  • October 9, 2023

@jamesb16otterill​  Thanks for the quick response. DateTimeConverter gives me an error feedback after using same configuration in your screenshot. My datetime field is in varchar. I switched it to datetime via attribute manager and it still does not work for me.


j.botterill
Evangelist
Forum|alt.badge.img+69

It's fine that it is varchar. First goal with dates is generally to convert it to FME format. Can you copy and paste one of the (date) values so I can test the syntax I suggested is correct


fme
Contributor
Forum|alt.badge.img+7
  • Author
  • Contributor
  • October 9, 2023

@jamesb16otterill​  This is the same format as above

5/10/2023 06:45 PM

 

Thanks!


david_r
Celebrity
  • October 9, 2023

@jamesb16otterill​  This is the same format as above 

5/10/2023 06:45 PM

 

Thanks!

Try using this format string in the DateTimeConverter:

%d/%m/%Y %I:%M %p

The difference lies in using %I (12 hours) rather than %H (24 hours) for the hour part.

Result:

20231005184500

 


fme
Contributor
Forum|alt.badge.img+7
  • Author
  • Contributor
  • October 10, 2023

Try using this format string in the DateTimeConverter:

%d/%m/%Y %I:%M %p

The difference lies in using %I (12 hours) rather than %H (24 hours) for the hour part.

Result:

20231005184500

 

@david_r​  @jamesb16otterill​ this did not work either in a Datetime converter. However, I used it in @DateTimeParse in text editor and it worked. But after migrating this to a different version of FME: from 2023.0.1.0 to 2023.1.0.0, none of this worked. 

Thanks!


david_r
Celebrity
  • October 10, 2023

Try using this format string in the DateTimeConverter:

%d/%m/%Y %I:%M %p

The difference lies in using %I (12 hours) rather than %H (24 hours) for the hour part.

Result:

20231005184500

 

Weird... I tested it with 2023.1 and no issues.


fme
Contributor
Forum|alt.badge.img+7
  • Author
  • Contributor
  • October 10, 2023

@david_r​  I noticed the csv reader in the newer version reading in the year as a 2 digit year instead of 4 digits. This is why its failing.