Рассчитать фактические прошедшие дни в Filemaker?

1144
elhombre

Как сделать так, чтобы Filemaker всегда отдельно отображал фактические прошедшие дни с данной даты, сохраненные в поле в макете?

пример

Я ввожу сегодняшнюю дату в базу данных. Когда я смотрю на мой взгляд сегодня, там должно быть отдельное текстовое поле с надписью 0 дней. В течение одной недели это текстовое поле должно содержать 7 дней.

2
Вы когда-нибудь пробовали это ??? Ecnerwal 9 лет назад 0

2 ответа на вопрос

0
Ecnerwal

Поле StoredDate

Отдельное поле ElapsedDays

(текст? почему вы хотите, чтобы число было текстом? Преобразование оставлено для учащегося в качестве упражнения, если студент действительно этого хочет. Его легко найти ...)

ElapsedDays, тип расчета, кнопка [Опции] Get (CurrentDate) - StoredDate

Кнопка [Параметры хранения] Проверка Не сохранять результаты расчетов - при необходимости пересчитать

Если вы не измените параметры хранилища, оно будет запущено при создании и не изменится. Это ключевой параметр, позволяющий изменить его при изменении текущей даты.

Если по какой-то причудливой причине вы действительно хотите сохранить в поле неизменный текст «дней», а также число, что также можно сделать при расчете, это просто сделает его более утомительным.

GetAsText (Get (CurrentDate) - StoredDate) и «дни»

Итак, 480 дней спустя, даже не голосование? Я знаю, что прошло 480 дней с тех пор, как я ответил, потому что это работает, и у меня все еще есть тестовая БД, которую я бросил вместе, чтобы проверить это ...

0
bjbk

Of course, there are many ways to accomplish this. It would depend on your solution and how you want the calculation to appear on your layout.

Using FileMaker 14 this can be done without using an Unstored Calculation in your data table. You can take advantage of Filemaker's calculation engine directly on your layout using the Hide When calculation on a simple text object. A button could be used for this too.

Assuming you have a stored date in a field, let's call it Table::myDate in this example where Table is your table name and myDate is your date field with the date stored.

Layout

  • On your desired layout go into Layout Mode. ( +L OR control+L on Windows)
  • Insert a new Text object and type in a Merge Variable (Merge variables can be either Local or Global in scope. You can use a local variable in this case that will be discarded when the layout is left or refreshed.) You can use whatever you wish for a variable name, we'll use $daysElapsed in this example. So your text object will have <<$daysElapsed>> entered as text.
  • Go to the Data Tab in the Inspector Pane
  • Go to the Hide When calculation
  • Using Let() we can take advantage of Filemaker's calculation engine without having to add a field to the Table. Enter the a let statement like so:
    Let ( $daysElapsed = Get ( CurrentDate ) - Table::myDate ; False )
    This sets the $daysElapsed variable automatically on entry of the Layout. Thus displaying the days elapsed. Returning False as a result in the Let Statement allows the object to always be shown. See screenshots below.

To add text to this, simply add it in the calculation or it can be added directly in the text object before the Merge variable declaration. Like so:
Days elapsed: <<$daysElapsed>>

Layout Mode

Browse Mode

Days elapsed calculation

Inspector pane - Hide object when...