Skip to main content

Notifications

Microsoft Dynamics NAV (Archived)

Dates and Calcdate

Posted on by Microsoft Employee

I have a shipmentdate filter field (text).  I want to check this field for '.'  If there is no period than I want to change the shipmentdate filter to a range which will contain the date already in the filter plus the filter date +9D, and then insert back into the shipmentdate filter. I am getting a conversion error.  DATE := TEXT

*This post is locked for comments

  • Verified answer
    Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Dates and Calcdate

    I have found the answer about the missing filters showing for the headings and the problem was with the FILTERGROUP. It had changed it to 0 right after the checkdate and modification of field so passing the information was in filtergroup(2).  Thank you guys for all your help with the date!

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Dates and Calcdate

    I just reset the shipmentdate filter the table filters were passed to the report however the reportfilter and shipmentdate filter fields are empty, do u guys know how to fix that?  Is it some type of refresh after I have reset the shipment filter

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Dates and Calcdate

    So I did find out the problem was that the shipmentdatefilter field was blank. However, the reportfilters field, that shows all the filters combine is populated. But I think that the way I have to go about this is in the Page Action of the form right before it does the copyfilters to SalesHeader, have it check the shipmentdate filter field and see if it is a single date by doing above.  If it is a single date, make shipmentdate filter a range (single date - single date +9D), then do setfilter shipmentdate filter, then copyfilters  SalesHeader.  At this point, can I only set the shipmentdate filter and it will keep the rest of the filters that are already entered on the page, or do I need to SalesHeader.reset and reapply all the filters again.

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Dates and Calcdate

    Archer the Shipmentdatefilter field is a TEXT

  • Verified answer
    4BzSoftware Profile Picture
    4BzSoftware 6,071 on at
    RE: Dates and Calcdate

    Hi Kim,

    You can try below:

    //Declare lDat_ShipmentDate as Date local variable.

    //Keep what user inputed for values filter

    IF (DELCHR(ShipmentDateFilter, '=', '|&=<>') <> ShipmentDateFilter) OR (STRPOS(ShipmentDateFilter, '..') > 0) THEN

       EXIT;

    //Convert to Date

    IF EVALUATE(lDat_ShipmentDate, ShipmentDateFilter) THEN

     ShipmentDateFilter := STRSUBSTNO('%1..%2', lDat_ShipmentDate, CALCDATE('<+9D>', lDat_ShipmentDate));

  • mmv Profile Picture
    mmv 11,465 on at
    RE: Dates and Calcdate

    hi,

    From the above code, it seems that ShipmentDateFilter is variable of type Date.  It has to be of type Text.

    Best Regards,

    MMV

  • keoma Profile Picture
    keoma 32,675 on at
    RE: Dates and Calcdate

    is the filter variable of type date or text?

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Dates and Calcdate

    Even tried

    REFDATE := CALCDATE('<+9D>',ShipmentDateFilter)

    STILL DID NOT WORK

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Dates and Calcdate

    POS := STRPOS(ShipmentDateFilter,'..');

    IF POS = 0 THEN

     REFDATE := CALCDATE('+9D',ShipmentDateFilter)

      ShipmentDateFilter := ShipmentDateFilter + '..' + Format(REFDATE,0);

    ----------pos is integer and Refdate is date

    getting type conversion is not possible because 1 of the operators contains an invalid type,  DATE := Text

  • Verified answer
    keoma Profile Picture
    keoma 32,675 on at
    RE: Dates and Calcdate

    use Position := STRPOS(filter, '.')  - or better '..' instead of '.' - to check if the filter string contains a range.

    with endDate := CALCDATE('+9D', startDate); you get the end date for the range.

    for usage with the filter expression convert the endDate to string using format(endDate).

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

November Spotlight Star - Khushbu Rajvi

Congratulations to a top community star!

Forum Structure Changes Complete!

🔔 Be sure to subscribe to the new forums you are interested in to stay up to date! 🔔

Dynamics 365 Community Platform update – Oct 28

Welcome to the next edition of the Community Platform Update. This is a status …

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,113 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 229,918 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans