Is DateWithin30Days(Date 1, Date 2) an Apex Method?How to test a method within a classSimple Apex class to return a list of stringsInvalid Class/Method identifier, is this a bug?How to calculate duration between two dates(in months and days) using formula field?How to make a date parameter for a report URL more dynamic?How to retrieve start date and end date for fiscal month?Salesforce Cookbook - Last Chatter Date - Works MOST Of The TimeMethod Is Not Visible: APEX Trailhead Unit Testing ChallengeSet collection doesn't always enforce uniqueness with the Date datatype? Does the following example seem correct?Continuation Apex Unit Testing - Lightning

What are these arcade games in Ghostbusters 1984?

Grammar Question Regarding "Are the" or "Is the" When Referring to Something that May or May not be Plural

Construct a word ladder

Where have Brexit voters gone?

Employer asking for online access to bank account - Is this a scam?

Popcorn is the only acceptable snack to consume while watching a movie

Caught 2 students cheating together on the final exam that I proctored

I know that there is a preselected candidate for a position to be filled at my department. What should I do?

I unknowingly submitted plagarised work

Why is a `for` loop so much faster to count True values?

How to respond to an upset student?

Sitecore 9.0 works with solr 7.2.1?

Python program to take in two strings and print the larger string

Teacher help me explain this to my students

Is the Indo-European language family made up?

Apache redirect to https:/www only partially working

What are the mechanical differences between the uncommon Medallion of Thoughts and the rare Potion of Mind Reading?

The art of clickbait captions

Did 20% of US soldiers in Vietnam use heroin, 95% of whom quit afterwards?

Is it possible to play as a necromancer skeleton?

Installed Tankless Water Heater - Internet loss when active

Where's this lookout in Nova Scotia?

How do I partition a matrx into blocks and replace zeros with dots?

A Riley Respite



Is DateWithin30Days(Date 1, Date 2) an Apex Method?


How to test a method within a classSimple Apex class to return a list of stringsInvalid Class/Method identifier, is this a bug?How to calculate duration between two dates(in months and days) using formula field?How to make a date parameter for a report URL more dynamic?How to retrieve start date and end date for fiscal month?Salesforce Cookbook - Last Chatter Date - Works MOST Of The TimeMethod Is Not Visible: APEX Trailhead Unit Testing ChallengeSet collection doesn't always enforce uniqueness with the Date datatype? Does the following example seem correct?Continuation Apex Unit Testing - Lightning






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








1















I'm working on the #APEX Unit Testing unit on #TrailHead, and I saw what appears to be a very useful Date method, DateWithin30Days(date1, date2) This would be very useful for some of my projects, but I can't find it any where in the APEX documentation.



Here is the code sample:



public static Date CheckDates(Date date1, Date date2) 
//if date2 is within the next 30 days of date1, use date2. Otherwise use the end of the month
if(DateWithin30Days(date1,date2))
return date2;
else
return SetEndOfMonthDate(date1);











share|improve this question






















  • That's probably just a private method inside that particular class. If it was a Salesforce method, it would have a namespace, like System, Date, etc. Where is this code?

    – CommonCoreTawan
    8 hours ago











  • Short answer, no. The lack of prefix to that class tells me that either it's a method on the same class you're on or on a class that your class inherits from. Maybe you can find it within the trailhead you're on?

    – Sebastian Kessel
    8 hours ago


















1















I'm working on the #APEX Unit Testing unit on #TrailHead, and I saw what appears to be a very useful Date method, DateWithin30Days(date1, date2) This would be very useful for some of my projects, but I can't find it any where in the APEX documentation.



Here is the code sample:



public static Date CheckDates(Date date1, Date date2) 
//if date2 is within the next 30 days of date1, use date2. Otherwise use the end of the month
if(DateWithin30Days(date1,date2))
return date2;
else
return SetEndOfMonthDate(date1);











share|improve this question






















  • That's probably just a private method inside that particular class. If it was a Salesforce method, it would have a namespace, like System, Date, etc. Where is this code?

    – CommonCoreTawan
    8 hours ago











  • Short answer, no. The lack of prefix to that class tells me that either it's a method on the same class you're on or on a class that your class inherits from. Maybe you can find it within the trailhead you're on?

    – Sebastian Kessel
    8 hours ago














1












1








1


1






I'm working on the #APEX Unit Testing unit on #TrailHead, and I saw what appears to be a very useful Date method, DateWithin30Days(date1, date2) This would be very useful for some of my projects, but I can't find it any where in the APEX documentation.



Here is the code sample:



public static Date CheckDates(Date date1, Date date2) 
//if date2 is within the next 30 days of date1, use date2. Otherwise use the end of the month
if(DateWithin30Days(date1,date2))
return date2;
else
return SetEndOfMonthDate(date1);











share|improve this question














I'm working on the #APEX Unit Testing unit on #TrailHead, and I saw what appears to be a very useful Date method, DateWithin30Days(date1, date2) This would be very useful for some of my projects, but I can't find it any where in the APEX documentation.



Here is the code sample:



public static Date CheckDates(Date date1, Date date2) 
//if date2 is within the next 30 days of date1, use date2. Otherwise use the end of the month
if(DateWithin30Days(date1,date2))
return date2;
else
return SetEndOfMonthDate(date1);








apex date






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked 8 hours ago









Daniel RobertsDaniel Roberts

183




183












  • That's probably just a private method inside that particular class. If it was a Salesforce method, it would have a namespace, like System, Date, etc. Where is this code?

    – CommonCoreTawan
    8 hours ago











  • Short answer, no. The lack of prefix to that class tells me that either it's a method on the same class you're on or on a class that your class inherits from. Maybe you can find it within the trailhead you're on?

    – Sebastian Kessel
    8 hours ago


















  • That's probably just a private method inside that particular class. If it was a Salesforce method, it would have a namespace, like System, Date, etc. Where is this code?

    – CommonCoreTawan
    8 hours ago











  • Short answer, no. The lack of prefix to that class tells me that either it's a method on the same class you're on or on a class that your class inherits from. Maybe you can find it within the trailhead you're on?

    – Sebastian Kessel
    8 hours ago

















That's probably just a private method inside that particular class. If it was a Salesforce method, it would have a namespace, like System, Date, etc. Where is this code?

– CommonCoreTawan
8 hours ago





That's probably just a private method inside that particular class. If it was a Salesforce method, it would have a namespace, like System, Date, etc. Where is this code?

– CommonCoreTawan
8 hours ago













Short answer, no. The lack of prefix to that class tells me that either it's a method on the same class you're on or on a class that your class inherits from. Maybe you can find it within the trailhead you're on?

– Sebastian Kessel
8 hours ago






Short answer, no. The lack of prefix to that class tells me that either it's a method on the same class you're on or on a class that your class inherits from. Maybe you can find it within the trailhead you're on?

– Sebastian Kessel
8 hours ago











3 Answers
3






active

oldest

votes


















4














The method DateWithin30Days(Date 1, Date 2) that you have referred here is not a standard Date method.



It is though still an Apex method but declared right within the class where you see this code. You are most likely looking at this code from trailhead, which you can always utilize for your purpose.



//method to check if date2 is within the next 30 days of date1
private static Boolean DateWithin30Days(Date date1, Date date2)
//check for date2 being in the past
if( date2 < date1) return false;

//check that date2 is within (>=) 30 days of date1
Date date30Days = date1.addDays(30); //create a date 30 days away from date1
if( date2 >= date30Days ) return false;
else return true;






share|improve this answer























  • I literally just saw this in the class. I was expecting it to be declared at the top, not the bottom. Looks like the same is for SetMonthEndOfDate.

    – Daniel Roberts
    8 hours ago











  • It's easy and okay to miss things at times :)

    – Jayant Das
    8 hours ago


















3














Short answer, no.



The lack of prefix to that class tells me that either it's a method on the same class you're on or on a class that your class inherits from. Maybe you can find it within the trailhead you're on?



However, here is a way to do what you need, with a little more flexibility



public static Boolean DateWithinXDays(Date startDate, Date endDate, Integer days) 
return (startDate.daysBetween(endDate) <= days)






share|improve this answer


















  • 1





    Thanks for the heads up. That method helps, I figured I could write my own, but didn't want to waste the time if it was a standard method. It might be in the trailhead, but my hunch is that they did what you have here. Thanks.

    – Daniel Roberts
    8 hours ago











  • Jayant below pasted the code that exists in the Trailhead. Frankly, I kinda prefer this one...

    – Sebastian Kessel
    8 hours ago


















2














It's part of the sample code for Get Started With Apex Unit Tests. The link to the sample code is located in the Challenge section of the module.



You might want to complete the more recent and more thorough Unit Testing on the Lightning Platform module in lieu of, or in addition to, this module.






share|improve this answer























    Your Answer








    StackExchange.ready(function()
    var channelOptions =
    tags: "".split(" "),
    id: "459"
    ;
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function()
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled)
    StackExchange.using("snippets", function()
    createEditor();
    );

    else
    createEditor();

    );

    function createEditor()
    StackExchange.prepareEditor(
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: false,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: null,
    bindNavPrevention: true,
    postfix: "",
    imageUploader:
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    ,
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    );



    );













    draft saved

    draft discarded


















    StackExchange.ready(
    function ()
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsalesforce.stackexchange.com%2fquestions%2f263661%2fis-datewithin30daysdate-1-date-2-an-apex-method%23new-answer', 'question_page');

    );

    Post as a guest















    Required, but never shown

























    3 Answers
    3






    active

    oldest

    votes








    3 Answers
    3






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    4














    The method DateWithin30Days(Date 1, Date 2) that you have referred here is not a standard Date method.



    It is though still an Apex method but declared right within the class where you see this code. You are most likely looking at this code from trailhead, which you can always utilize for your purpose.



    //method to check if date2 is within the next 30 days of date1
    private static Boolean DateWithin30Days(Date date1, Date date2)
    //check for date2 being in the past
    if( date2 < date1) return false;

    //check that date2 is within (>=) 30 days of date1
    Date date30Days = date1.addDays(30); //create a date 30 days away from date1
    if( date2 >= date30Days ) return false;
    else return true;






    share|improve this answer























    • I literally just saw this in the class. I was expecting it to be declared at the top, not the bottom. Looks like the same is for SetMonthEndOfDate.

      – Daniel Roberts
      8 hours ago











    • It's easy and okay to miss things at times :)

      – Jayant Das
      8 hours ago















    4














    The method DateWithin30Days(Date 1, Date 2) that you have referred here is not a standard Date method.



    It is though still an Apex method but declared right within the class where you see this code. You are most likely looking at this code from trailhead, which you can always utilize for your purpose.



    //method to check if date2 is within the next 30 days of date1
    private static Boolean DateWithin30Days(Date date1, Date date2)
    //check for date2 being in the past
    if( date2 < date1) return false;

    //check that date2 is within (>=) 30 days of date1
    Date date30Days = date1.addDays(30); //create a date 30 days away from date1
    if( date2 >= date30Days ) return false;
    else return true;






    share|improve this answer























    • I literally just saw this in the class. I was expecting it to be declared at the top, not the bottom. Looks like the same is for SetMonthEndOfDate.

      – Daniel Roberts
      8 hours ago











    • It's easy and okay to miss things at times :)

      – Jayant Das
      8 hours ago













    4












    4








    4







    The method DateWithin30Days(Date 1, Date 2) that you have referred here is not a standard Date method.



    It is though still an Apex method but declared right within the class where you see this code. You are most likely looking at this code from trailhead, which you can always utilize for your purpose.



    //method to check if date2 is within the next 30 days of date1
    private static Boolean DateWithin30Days(Date date1, Date date2)
    //check for date2 being in the past
    if( date2 < date1) return false;

    //check that date2 is within (>=) 30 days of date1
    Date date30Days = date1.addDays(30); //create a date 30 days away from date1
    if( date2 >= date30Days ) return false;
    else return true;






    share|improve this answer













    The method DateWithin30Days(Date 1, Date 2) that you have referred here is not a standard Date method.



    It is though still an Apex method but declared right within the class where you see this code. You are most likely looking at this code from trailhead, which you can always utilize for your purpose.



    //method to check if date2 is within the next 30 days of date1
    private static Boolean DateWithin30Days(Date date1, Date date2)
    //check for date2 being in the past
    if( date2 < date1) return false;

    //check that date2 is within (>=) 30 days of date1
    Date date30Days = date1.addDays(30); //create a date 30 days away from date1
    if( date2 >= date30Days ) return false;
    else return true;







    share|improve this answer












    share|improve this answer



    share|improve this answer










    answered 8 hours ago









    Jayant DasJayant Das

    21.8k21433




    21.8k21433












    • I literally just saw this in the class. I was expecting it to be declared at the top, not the bottom. Looks like the same is for SetMonthEndOfDate.

      – Daniel Roberts
      8 hours ago











    • It's easy and okay to miss things at times :)

      – Jayant Das
      8 hours ago

















    • I literally just saw this in the class. I was expecting it to be declared at the top, not the bottom. Looks like the same is for SetMonthEndOfDate.

      – Daniel Roberts
      8 hours ago











    • It's easy and okay to miss things at times :)

      – Jayant Das
      8 hours ago
















    I literally just saw this in the class. I was expecting it to be declared at the top, not the bottom. Looks like the same is for SetMonthEndOfDate.

    – Daniel Roberts
    8 hours ago





    I literally just saw this in the class. I was expecting it to be declared at the top, not the bottom. Looks like the same is for SetMonthEndOfDate.

    – Daniel Roberts
    8 hours ago













    It's easy and okay to miss things at times :)

    – Jayant Das
    8 hours ago





    It's easy and okay to miss things at times :)

    – Jayant Das
    8 hours ago













    3














    Short answer, no.



    The lack of prefix to that class tells me that either it's a method on the same class you're on or on a class that your class inherits from. Maybe you can find it within the trailhead you're on?



    However, here is a way to do what you need, with a little more flexibility



    public static Boolean DateWithinXDays(Date startDate, Date endDate, Integer days) 
    return (startDate.daysBetween(endDate) <= days)






    share|improve this answer


















    • 1





      Thanks for the heads up. That method helps, I figured I could write my own, but didn't want to waste the time if it was a standard method. It might be in the trailhead, but my hunch is that they did what you have here. Thanks.

      – Daniel Roberts
      8 hours ago











    • Jayant below pasted the code that exists in the Trailhead. Frankly, I kinda prefer this one...

      – Sebastian Kessel
      8 hours ago















    3














    Short answer, no.



    The lack of prefix to that class tells me that either it's a method on the same class you're on or on a class that your class inherits from. Maybe you can find it within the trailhead you're on?



    However, here is a way to do what you need, with a little more flexibility



    public static Boolean DateWithinXDays(Date startDate, Date endDate, Integer days) 
    return (startDate.daysBetween(endDate) <= days)






    share|improve this answer


















    • 1





      Thanks for the heads up. That method helps, I figured I could write my own, but didn't want to waste the time if it was a standard method. It might be in the trailhead, but my hunch is that they did what you have here. Thanks.

      – Daniel Roberts
      8 hours ago











    • Jayant below pasted the code that exists in the Trailhead. Frankly, I kinda prefer this one...

      – Sebastian Kessel
      8 hours ago













    3












    3








    3







    Short answer, no.



    The lack of prefix to that class tells me that either it's a method on the same class you're on or on a class that your class inherits from. Maybe you can find it within the trailhead you're on?



    However, here is a way to do what you need, with a little more flexibility



    public static Boolean DateWithinXDays(Date startDate, Date endDate, Integer days) 
    return (startDate.daysBetween(endDate) <= days)






    share|improve this answer













    Short answer, no.



    The lack of prefix to that class tells me that either it's a method on the same class you're on or on a class that your class inherits from. Maybe you can find it within the trailhead you're on?



    However, here is a way to do what you need, with a little more flexibility



    public static Boolean DateWithinXDays(Date startDate, Date endDate, Integer days) 
    return (startDate.daysBetween(endDate) <= days)







    share|improve this answer












    share|improve this answer



    share|improve this answer










    answered 8 hours ago









    Sebastian KesselSebastian Kessel

    9,43262239




    9,43262239







    • 1





      Thanks for the heads up. That method helps, I figured I could write my own, but didn't want to waste the time if it was a standard method. It might be in the trailhead, but my hunch is that they did what you have here. Thanks.

      – Daniel Roberts
      8 hours ago











    • Jayant below pasted the code that exists in the Trailhead. Frankly, I kinda prefer this one...

      – Sebastian Kessel
      8 hours ago












    • 1





      Thanks for the heads up. That method helps, I figured I could write my own, but didn't want to waste the time if it was a standard method. It might be in the trailhead, but my hunch is that they did what you have here. Thanks.

      – Daniel Roberts
      8 hours ago











    • Jayant below pasted the code that exists in the Trailhead. Frankly, I kinda prefer this one...

      – Sebastian Kessel
      8 hours ago







    1




    1





    Thanks for the heads up. That method helps, I figured I could write my own, but didn't want to waste the time if it was a standard method. It might be in the trailhead, but my hunch is that they did what you have here. Thanks.

    – Daniel Roberts
    8 hours ago





    Thanks for the heads up. That method helps, I figured I could write my own, but didn't want to waste the time if it was a standard method. It might be in the trailhead, but my hunch is that they did what you have here. Thanks.

    – Daniel Roberts
    8 hours ago













    Jayant below pasted the code that exists in the Trailhead. Frankly, I kinda prefer this one...

    – Sebastian Kessel
    8 hours ago





    Jayant below pasted the code that exists in the Trailhead. Frankly, I kinda prefer this one...

    – Sebastian Kessel
    8 hours ago











    2














    It's part of the sample code for Get Started With Apex Unit Tests. The link to the sample code is located in the Challenge section of the module.



    You might want to complete the more recent and more thorough Unit Testing on the Lightning Platform module in lieu of, or in addition to, this module.






    share|improve this answer



























      2














      It's part of the sample code for Get Started With Apex Unit Tests. The link to the sample code is located in the Challenge section of the module.



      You might want to complete the more recent and more thorough Unit Testing on the Lightning Platform module in lieu of, or in addition to, this module.






      share|improve this answer

























        2












        2








        2







        It's part of the sample code for Get Started With Apex Unit Tests. The link to the sample code is located in the Challenge section of the module.



        You might want to complete the more recent and more thorough Unit Testing on the Lightning Platform module in lieu of, or in addition to, this module.






        share|improve this answer













        It's part of the sample code for Get Started With Apex Unit Tests. The link to the sample code is located in the Challenge section of the module.



        You might want to complete the more recent and more thorough Unit Testing on the Lightning Platform module in lieu of, or in addition to, this module.







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered 8 hours ago









        David ReedDavid Reed

        43.3k82564




        43.3k82564



























            draft saved

            draft discarded
















































            Thanks for contributing an answer to Salesforce Stack Exchange!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid


            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.

            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsalesforce.stackexchange.com%2fquestions%2f263661%2fis-datewithin30daysdate-1-date-2-an-apex-method%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            Sahara Skak | Bilen | Luke uk diar | NawigatsjuunCommonskategorii: SaharaWikivoyage raisfeerer: Sahara26° N, 13° O

            The fall designs the understood secretary. Looking glass Science Shock Discovery Hot Everybody Loves Raymond Smile 곳 서비스 성실하다 Defas Kaloolon Definition: To combine or impregnate with sulphur or any of its compounds as to sulphurize caoutchouc in vulcanizing Flame colored Reason Useful Thin Help 갖다 유명하다 낙엽 장례식 Country Iron Definition: A fencer a gladiator one who exhibits his skill in the use of the sword Definition: The American black throated bunting Spiza Americana Nostalgic Needy Method to my madness 시키다 평가되다 전부 소설가 우아하다 Argument Tin Feeling Representative Gym Music Gaur Chicken 일쑤 코치 편 학생증 The harbor values the sugar. Vasagle Yammoe Enstatite Definition: Capable of being limited Road Neighborly Five Refer Built Kangaroo 비비다 Degree Release Bargain Horse 하루 형님 유교 석 동부 괴롭히다 경제력

            19. јануар Садржај Догађаји Рођења Смрти Празници и дани сећања Види још Референце Мени за навигацијуу