web
You’re offline. This is a read only version of the page.
close
Skip to main content
Community site session details

Community site session details

Session Id :
Microsoft Dynamics NAV (Archived)

Dates and Calcdate

(0) ShareShare
ReportReport
Posted on by

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

I have the same question (0)
  • Verified answer
    keoma Profile Picture
    32,729 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).

  • Community Member Profile Picture
    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

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

    Even tried

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

    STILL DID NOT WORK

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

    is the filter variable of type date or text?

  • mmv Profile Picture
    11,471 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

  • Verified answer
    4BzSoftware Profile Picture
    6,073 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));

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

    Archer the Shipmentdatefilter field is a TEXT

  • Community Member Profile Picture
    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
    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

  • Verified answer
    Community Member Profile Picture
    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!

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics NAV (Archived)

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans