How to create the first date when I have the month and year

Hi!!!
I have one field(datatype=code) named Period. If it has value as 2016_01 then I need to get the First Date of January of that year i.e 01/01/2016, if it is 2015_08 then 01/08/2015, this way. How can I do that? any suggestion?

Thanks in advance..

Best Answer

Answers

  • RockWithNAVRockWithNAV Member Posts: 1,139
    Hey Anirbance,

    The format of this 2016_01 will always be same OR it may change something like 01_2016 or it will always be in this format 2016_01?
  • anirbancseanirbancse Member Posts: 20
    It will always be like that..2016_01,2016_02...2017_01 and so on..
  • swpoloswpolo Member Posts: 80
    Hi Anirbancse,

    Is it that solutuon you would like to have?

    Datestr2:=CONVERTSTR(Datestr, '_', ',');

    evaluate(dateVar,strsubstno('01/%2/%3',SELECTSTR(2, Datestr2),SELECTSTR(1, Datestr2));

    you will have required date in dateVar. :)

    Nav Upgrades and DEV outsourcing
    Reports transformation to RDLC
    List -1h , Complex List -3h, Document -4h (dev hours)
    navisionupgrade.com
  • m_bergerm_berger Member Posts: 7
    edited 2016-04-28
    another option :

    evaluate(Year, copystr(datestr,1,4));
    evaluate(Month, copystr(datestr,6,2));

    Datevar := DMY2Date(1,month,year);
  • anirbancseanirbancse Member Posts: 20
    Hi all,

    Thanks for your repiles.

    @RockWithNAV : I got it working following your step. Thanks. My code is as followed and it is working fine.


    IF RecABC.FINDFIRST THEN BEGIN
    year := COPYSTR(RecABC."Invoicing Period",1,4);
    month := COPYSTR(RecABC."Invoicing Period",6,7);
    EVALUATE(DateFrom,'01'+'/'+month+'/'+year);
    DateTo := CLOSINGDATE(DateFrom);
    END
    Invoicing Period = 2016_01,2016_02..this way..
    o/p: DateFrom = 01/01/2016 and DateTo = 31/01/2016.

    Thank you guys..
Sign In or Register to comment.