Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics NAV (Archived)

Pick 1 Date From Date Range

(0) ShareShare
ReportReport
Posted on by Microsoft Employee

I want to enter a date range like 010114..093014 & after that i want to pick 1st date from date range. How can it be possible? Plz Suggest.

Thanks

*This post is locked for comments

  • Suggested answer
    4BzSoftware Profile Picture
    4BzSoftware 6,071 on at
    RE: Pick 1 Date From Date Range

    Hi Siddhartha,

    GETRANGEMIN can help you. I use Posting Date of Sales Header as Jonathan in below example, but you can use any record that has a Date field:

    lRec_SalesHeader.SETFILTER("Posting Date", '010114..093014');

    MESSAGE('%1', lRec_SalesHeader.GETRANGEMIN("Posting Date"));

  • Suggested answer
    keoma Profile Picture
    keoma 32,675 on at
    RE: Pick 1 Date From Date Range

    // variables: dateFilterString,convString,strDate1,strDate2 of type Text

    dateFilterString := '010114..093014';

    convString := CONVERTSTR(dateFilterString,'..',',');

    strDate1 := SELECTSTR(1,convString);

    strDate1 := SELECTSTR(2,convString);

    // variables: date1,date2 of type Date

    EVALUATE(date1, strDate1);

    EVALUATE(date2, strDate2);

    salesHeader.SETRANGE(salesHeader."Posting Date",date1,date2);

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Pick 1 Date From Date Range

    Actually it is separate text type variable like account schedule report date filter. i need to split that date range.

  • Suggested answer
    keoma Profile Picture
    keoma 32,675 on at
    RE: Pick 1 Date From Date Range

    hi

    salesHeader.SETRANGE(salesHeader."Posting Date",010114D,093014D);

    IF salesHeader.FINDFIRST THEN

     MESSAGE(FORMAT(salesHeader."Posting Date"));

  • Suggested answer
    Saurabh Shah Profile Picture
    Saurabh Shah 4,560 on at
    RE: Pick 1 Date From Date Range

    Hi,

    First use Table.SETCURRENTKEY with Key field like posting date. (date field should be the first field in your key)

    User the setfilter with %1..%2

    after above do Findfirst and go with the record.

    If you look at any other information then please provide more details so we can suggest.

    Small Example:

     BankAccLedgEntry.RESET;

     BankAccLedgEntry.SETCURRENTKEY("Bank Account No.","Global Dimension 1 Code",

       "Global Dimension 2 Code","Posting Date","Location Code");

     BankAccLedgEntry.SETRANGE("Bank Account No.","No.");

     BankAccLedgEntry.SETFILTER("Posting Date",'%1..%2',0D,NORMALDATE(GETRANGEMIN("Date Filter")) - 1);

    IF FINDFIRST THEN

    Regards,

    Saurabh Shah

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

Congratulations 2024 Spotlight Honorees

Kudos to all of our 2024 community stars! 🎉

Meet the Top 10 leaders for December

Congratulations to our December super stars! 🥳

Start Your Super User Journey

Join the ranks of our community heros! 🦹

Leaderboard

#1
André Arnaud de Calavon Profile Picture

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

#2
Martin Dráb Profile Picture

Martin Dráb 230,458 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans