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;
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
add a comment |
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
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
add a comment |
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
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
apex date
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
add a comment |
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
add a comment |
3 Answers
3
active
oldest
votes
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;
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
add a comment |
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)
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
add a comment |
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.
add a comment |
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
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
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;
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
add a comment |
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;
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
add a comment |
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;
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;
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
add a comment |
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
add a comment |
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)
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
add a comment |
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)
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
add a comment |
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)
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)
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
add a comment |
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
add a comment |
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.
add a comment |
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.
add a comment |
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.
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.
answered 8 hours ago
David Reed♦David Reed
43.3k82564
43.3k82564
add a comment |
add a comment |
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.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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
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