Options

Dateformula

dabba23dabba23 Member Posts: 77
I have a dateformula: 4M. Is it possible to turn it into an integer?


Thanks
Ann

Comments

  • Marije_BrummelMarije_Brummel Member, Moderators Design Patterns Posts: 4,262
    Do you mean an integer telling how many days or how many months?
  • dabba23dabba23 Member Posts: 77
    I want to know the number of months!!!
  • Marije_BrummelMarije_Brummel Member, Moderators Design Patterns Posts: 4,262
    1. You can do a format on the field and remove the 'M'

    2. Or calculate 4M from 1st of january, put a filter on the date table with filter on months and count the records.

    1st option is the easiest but won't work with all languages, 2nd option is more work but better I think.
  • dabba23dabba23 Member Posts: 77
    I have tried the format, maybe you can tell me where im going wrong on the syntax:

    IntLength := Format(PeriodLength,-'M');

    Error message: Integer := Text

    IntLength, datatype Integer
    PeriodLength, datatype Dateformula

    Makes no difference leaving -M outside brackets
  • DenSterDenSter Member Posts: 8,307
    FORMAT returns a text value, and you can't set an integer value directly to a text value. You will need to do EVALUATE(MyInt,MyText).

    As far as using FORMAT to get rid of the M, I'd like to see how that works too :). Come on Mark, it's been at least more than 6 minutes! What's keeping you so long? :-k
  • krikikriki Member, Moderator Posts: 9,120
    Try this:
    txt := FORMAT(MyDateFormula);
    txt := DELCHR(txt,'=',DELCHR(txt,'=','1234567890'));
    EVALUATE(int,txt);
    
    Regards,Alain Krikilion
    No PM,please use the forum. || May the <SOLVED>-attribute be in your title!


  • Marije_BrummelMarije_Brummel Member, Moderators Design Patterns Posts: 4,262
    DenSter wrote:
    Come on Mark, it's been at least more than 6 minutes! What's keeping you so long? :-k

    Gone home, picked up my daughter at my in-laws, eating, stuff like that :D
Sign In or Register to comment.