Using 'AutoFormatExpr' to get the year-part of a date

jensthomsenjensthomsen Member Posts: 173
Hi
I have a field in a table of type 'Date'. Now I want to show only the year-part (that is '2004' for date 12-12-2004 and so on). I'm able to do it directly on the form, but instead of having to code this on every form using this field, I will do it directly on the table...Does anyone know how to do this? I think we have to use the tablefield-properies 'AutoFormatType' and 'AutoFormatExpr' ...but how???

Comments

  • AlbertvhAlbertvh Member Posts: 516
    Hi
    on the SourceExpr you could do this
    FORMAT(FieldName,0,'<Year4>')

    Hope it helps

    <edit> sorry this on the form itself maybe you could use this in the autoformat <edit>
  • jensthomsenjensthomsen Member Posts: 173
    Albertvh wrote:
    Hi
    on the SourceExpr you could do this
    FORMAT(FieldName,0,'<Year4>')

    Hope it helps

    <edit> sorry this on the form itself maybe you could use this in the autoformat <edit>

    Yes, but thats only on forms:-)
  • ar4ijsar4ijs Member Posts: 24
    I think AutoFormatType and AutoFormatExpr are for Decimals only, to set decimal places and add some text. I've even tried to modify AutoFormatTranslate function in C1 but no success.
    So far I couldn't format field in table.

    BTW you don't have to code in forms, just use Format property of TextBox.
Sign In or Register to comment.