INTERACT FORUM

More => Old Versions => Media Center 17 => Topic started by: carbo on November 19, 2011, 11:07:03 am

Title: Expression to modify date field
Post by: carbo on November 19, 2011, 11:07:03 am
I have some problems with date fields of images taken at different time zones.
After some holidays, i have gathered pictures taken by all group members.
The problem is that not all of them have set correctly the time of their camera.
So in media center some pictures taken at the same time have dates seperated by 5 hours which mess all my sorting.

I have tried the expressions "=[Date]+300" or "=[Date]-300" but both of them remove 5 hours and i want to add 5 hours...

Any idea to fix my metada ?

Thanks,

Guillaume
Title: Re: Expression to modify date field
Post by: MrC on November 19, 2011, 12:33:41 pm
Assuming 5 hours ahead...

   formatdate(math([date,0]+(5/24)), datetime)

Use subtraction to adjust 5 hours behind.
Title: Re: Expression to modify date field
Post by: carbo on November 20, 2011, 12:33:28 pm
Thanks for the quick answer but unfortunately your expression doesn't seem to work.
When I try it, the date returned is blank

Any idea why ?
Title: Re: Expression to modify date field
Post by: MrC on November 20, 2011, 12:51:08 pm
Create an expression column in a pane, and enter exactly the expression shown.  Does that work?  Works here.

The minutes portion will be off by up to about 4 minutes for times late in the day, due to round off error.
Title: Re: Expression to modify date field
Post by: carbo on November 20, 2011, 01:05:10 pm
It's not working for me  :(
All my files have "unassigned" value except the one with the date "2011"

I wonder if the problem comes from my locale where the date format is "DD/MM/YYYY HH:MM:SS"
Title: Re: Expression to modify date field
Post by: MrC on November 20, 2011, 01:29:40 pm
What are the values of [Date] for the files in question?  Show that column.
Title: Re: Expression to modify date field
Post by: carbo on November 20, 2011, 02:00:43 pm
Here is the screenshot
Title: Re: Expression to modify date field
Post by: MrC on November 20, 2011, 02:49:11 pm
If you look at the raw date values, you should see they look like those shown in the screenshot.  The expression column is: [Date,0].  These are just floating point numbers.  MC does date conversion upon display, so your dates will be expressed in the locale's format, and locale should not affect the internal value of the date.

Possibly when you tried to assign the date field

  "=[Date]+300" or "=[Date]-300"

you modified the type from a floating point to a string.
Title: Re: Expression to modify date field
Post by: Lasse_Lus on November 20, 2011, 04:34:49 pm
math(function) and decimals in MC needs "dots"

does this work ?

formatdate(math(replace([date,0],/,,.)+0.208333),datetime)
Title: Re: Expression to modify date field
Post by: MrC on November 20, 2011, 05:00:27 pm
No dots required.
Title: Re: Expression to modify date field
Post by: Lasse_Lus on November 20, 2011, 05:07:45 pm
but C, your system is set to use dots is it not ?, my is ","
Title: Re: Expression to modify date field
Post by: carbo on November 21, 2011, 12:15:37 pm
Lasse is right ! with the replacement of , by . the expression now works !
It may be a bug of the math expression ?

Anyway thanks for the both of you, my problem is resolved !
Title: Re: Expression to modify date field
Post by: MrC on November 21, 2011, 12:55:20 pm
This is a little disturbing, but good to know.

Perhaps the Math() entry for the expression page in the wiki should be updated to indicate that for locales that do not use dot as a decimal, the workaround is required.
Title: Re: Expression to modify date field
Post by: Matt on November 21, 2011, 02:43:43 pm
Lasse is right ! with the replacement of , by . the expression now works !

The math parser supports functions, where parameters are delimited by commas.  This means it's pretty tough to allow a comma to be the decimal.

For example, imagine:
Math(min(1.2,2.21))

Now rewrite it using commas instead, and you'll see what a mess it would be for a parser:
Math(min(1,2,2,21))