Report- Format Date MMYY

fredp1fredp1 Member Posts: 86
Hi,

How do I format a field on a report to show in a MMYY format instead of DDMMYY?

Thanks
Fred

Comments

  • krikikriki Member, Moderator Posts: 9,118
    this is one way:
    txtYear := FORMAT(DATE2DMY(TODAY,3) MOD 100);
    txtMonth := FORMAT(DATE2DMY(TODAY,2) MOD 100);
    IF strlen(txtyear) = 1 then
      txtyear := '0' + txtyear;
    IF strlen(txtmonth) = 1 then
      txtmonth := '0' + txtmonth;
    
    
    txt := txtMonth + '/' + txtYear;
    
    Regards,Alain Krikilion
    No PM,please use the forum. || May the <SOLVED>-attribute be in your title!


  • BeliasBelias Member Posts: 2,998
    or this method:
    format(mytable."posting date",0,'<Month,2>/<Year,2>')
    

    @kriki: :? can you explain your code to us little terrains? :mrgreen:

    i understood, but...are you joking or i am not smart enough?It's a quite hard coded method, is there a particular reason to use your method instead of mine?
    -Mirko-
    "Never memorize what you can easily find in a book".....Or Mibuso
    My Blog
  • krikikriki Member, Moderator Posts: 9,118
    Belias wrote:
    or this method:
    format(mytable."posting date",0,'<Month,2>/<Year,2>')
    

    @kriki: :? can you explain your code to us little terrains? :mrgreen:

    i understood, but...are you joking or i am not smart enough?It's a quite hard coded method, is there a particular reason to use your method instead of mine?
    That after 10 years of NAV, I still can't use the format string of NAV :whistle:
    Maybe also because I created my own that is a lot easier to use (it is based on the Progress format string).
    Regards,Alain Krikilion
    No PM,please use the forum. || May the <SOLVED>-attribute be in your title!


  • BeliasBelias Member Posts: 2,998
    kriki wrote:
    Belias wrote:
    or this method:
    format(mytable."posting date",0,'<Month,2>/<Year,2>')
    

    @kriki: :? can you explain your code to us little terrains? :mrgreen:

    i understood, but...are you joking or i am not smart enough?It's a quite hard coded method, is there a particular reason to use your method instead of mine?
    That after 10 years of NAV, I still can't use the format string of NAV :whistle:
    Maybe also because I created my own that is a lot easier to use (it is based on the Progress format string).
    eheh...i've had to press F1 to remember how to format like this :whistle:
    it's incredibely difficult to remember all the faces of this function :lol:
    -Mirko-
    "Never memorize what you can easily find in a book".....Or Mibuso
    My Blog
  • krikikriki Member, Moderator Posts: 9,118
    Belias wrote:
    eheh...i've had to press F1 to remember how to format like this :whistle:
    it's incredibely difficult to remember all the faces of this function :lol:
    And it is difficult to use, with long formatting strings.
    If I want a date, I do this:
    DD/MM/YYYY for European format
    MM/DD/YYYY for US format
    YYYY/MM/DD for best format
    YYYYMMDD for a format I can easily convert in an integer.
    And I can also use MMMMMM to write the month completely. Or M######### to remove blanks for "May".
    Regards,Alain Krikilion
    No PM,please use the forum. || May the <SOLVED>-attribute be in your title!


  • AlbertvhAlbertvh Member Posts: 516
    Hi

    I know that I also had a lot of trouble with the FORMAT statement but dates are pretty simple
    FORMAT("Posting Date",0,'<Day>/<Month>/<Year>');   gives 1/01/09 dd/mm/yy
    FORMAT("Posting Date",0,'<Day>/<Month>/<Year4>'); gives 1/01/2009  dd/mm/yyyy
    FORMAT("Posting Date",0,'<Day> <Month Text> <Year>'); gives 1 January 09
    FORMAT("Posting Date",0,'<Day> <Month Text,3> <Year4>'); gives 1 Jan 2009
    

    Hope this helps a bit with the frustrations :)


    Albert
Sign In or Register to comment.