INTERACT FORUM

Please login or register.

Login with username, password and session length
Advanced search  
Pages: [1]   Go Down

Author Topic: Expression to modify date field  (Read 1932 times)

carbo

  • World Citizen
  • ***
  • Posts: 106
Expression to modify date field
« 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
Logged

MrC

  • Citizen of the Universe
  • *****
  • Posts: 10462
  • Your life is short. Give me your money.
Re: Expression to modify date field
« Reply #1 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.
Logged
The opinions I express represent my own folly.

carbo

  • World Citizen
  • ***
  • Posts: 106
Re: Expression to modify date field
« Reply #2 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 ?
Logged

MrC

  • Citizen of the Universe
  • *****
  • Posts: 10462
  • Your life is short. Give me your money.
Re: Expression to modify date field
« Reply #3 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.
Logged
The opinions I express represent my own folly.

carbo

  • World Citizen
  • ***
  • Posts: 106
Re: Expression to modify date field
« Reply #4 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"
Logged

MrC

  • Citizen of the Universe
  • *****
  • Posts: 10462
  • Your life is short. Give me your money.
Re: Expression to modify date field
« Reply #5 on: November 20, 2011, 01:29:40 pm »

What are the values of [Date] for the files in question?  Show that column.
Logged
The opinions I express represent my own folly.

carbo

  • World Citizen
  • ***
  • Posts: 106
Re: Expression to modify date field
« Reply #6 on: November 20, 2011, 02:00:43 pm »

Here is the screenshot
Logged

MrC

  • Citizen of the Universe
  • *****
  • Posts: 10462
  • Your life is short. Give me your money.
Re: Expression to modify date field
« Reply #7 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.
Logged
The opinions I express represent my own folly.

Lasse_Lus

  • Citizen of the Universe
  • *****
  • Posts: 999
Re: Expression to modify date field
« Reply #8 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)
Logged
MT5FR

MrC

  • Citizen of the Universe
  • *****
  • Posts: 10462
  • Your life is short. Give me your money.
Re: Expression to modify date field
« Reply #9 on: November 20, 2011, 05:00:27 pm »

No dots required.
Logged
The opinions I express represent my own folly.

Lasse_Lus

  • Citizen of the Universe
  • *****
  • Posts: 999
Re: Expression to modify date field
« Reply #10 on: November 20, 2011, 05:07:45 pm »

but C, your system is set to use dots is it not ?, my is ","
Logged
MT5FR

carbo

  • World Citizen
  • ***
  • Posts: 106
Re: Expression to modify date field
« Reply #11 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 !
Logged

MrC

  • Citizen of the Universe
  • *****
  • Posts: 10462
  • Your life is short. Give me your money.
Re: Expression to modify date field
« Reply #12 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.
Logged
The opinions I express represent my own folly.

Matt

  • Administrator
  • Citizen of the Universe
  • *****
  • Posts: 42002
  • Shoes gone again!
Re: Expression to modify date field
« Reply #13 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))
Logged
Matt Ashland, JRiver Media Center
Pages: [1]   Go Up