Results 1 to 10 of 10

Thread: Help - Formula

  1. #1
    Join Date
    Oct 2009
    Posts
    5

    Unhappy Unanswered: Help - Formula

    Guys, I wonder if I can help make a formula. I asked in my service, but it is not my area ... .. haha ...would be the following:

    Exists in the database variables Closing Date (DataEncerramento) and the Opening Date (DataInicio).

    He stated that when the closing date was greater than two months of opening date will appear FL.

    If the closing date is less than two months after the opening date appeared FI.

    Could anyone help me? Thank you very much!

    (and sorry by English)
    Last edited by FelipeSenna; 10-13-09 at 13:50.

  2. #2
    Join Date
    Jan 2003
    Location
    British Columbia
    Posts
    44
    Code:
    If DateAdd("m",2, {DataInicio.OpeningDate}) > {DataEncerramento.ClosingDate} Then
       "FI"
    Else 
       "FL"

  3. #3
    Join Date
    Oct 2009
    Posts
    5
    Hi...thanks!

    But, the system show this message: "A date-time is required here."

  4. #4
    Join Date
    Jan 2003
    Location
    British Columbia
    Posts
    44
    Your database fields are not true Date fields, they are probably String fields that happen to contain date values.

    You will need to convert the database fields to Dates before you can use the DateAdd function.

    The DateValue function might work for you, assuming the date values are all stored using the same format.
    Last edited by brucevde; 10-13-09 at 15:20.

  5. #5
    Join Date
    Oct 2009
    Posts
    5
    Thanks by the help...

    Anyone other sugestion?

    Thank very much!

  6. #6
    Join Date
    Jan 2007
    Location
    UK
    Posts
    11,434
    Provided Answers: 10
    What is your database backend? SQL Server, MySQL, Access..?
    George
    Home | Blog

  7. #7
    Join Date
    Oct 2009
    Posts
    5
    Access...

    thanks

  8. #8
    Join Date
    Jan 2007
    Location
    UK
    Posts
    11,434
    Provided Answers: 10
    I suggest you change your query in access: add an extra column:
    Code:
    SELECT ...
         , Iif(DateAdd("m",2, OpeningDate) > ClosingDate, "FI", "FL")
    FROM   ...
    George
    Home | Blog

  9. #9
    Join Date
    Oct 2009
    Posts
    5
    Unfortunately, I can not do that.

    This is a report that will be generated by a system developed for the company that I work.

    Thanks!

  10. #10
    Join Date
    Jan 2003
    Location
    British Columbia
    Posts
    44
    Anyone other sugestion?
    Did you try

    Code:
    If DateAdd("m",2, DateValue({DataInicio.OpeningDate})) > DateValue({DataEncerramento.ClosingDate}) Then
       "FI"
    Else 
       "FL"
    If that doesn't work give us some more information! How are the dates stored in the database? What format?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •