Skip to main content

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!

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


@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.


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


@jamesb16otterill​  This is the same format as above

5/10/2023 06:45 PM

 

Thanks!


@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

 


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!


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.


@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.


Reply