Validation rule - created date < FIXED DATE





.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty{ margin-bottom:0;
}






up vote
2
down vote

favorite












I'm trying to add a line to a set of existing validation rules so they only apply to opportunities created prior to a fixed date. Let's say 10/31/2018. I thought it would be pretty straightforward as



CreatedDate < 10/31/2018



So the entire rule would read:



ISPICKVAL ( StageName, "Demo")&&



Clinical_Buyer__c = FALSE&&



CreatedDate < 10/31/2018



I keep getting the error that the '<' was expecting a DateTime received Number.










share|improve this question




























    up vote
    2
    down vote

    favorite












    I'm trying to add a line to a set of existing validation rules so they only apply to opportunities created prior to a fixed date. Let's say 10/31/2018. I thought it would be pretty straightforward as



    CreatedDate < 10/31/2018



    So the entire rule would read:



    ISPICKVAL ( StageName, "Demo")&&



    Clinical_Buyer__c = FALSE&&



    CreatedDate < 10/31/2018



    I keep getting the error that the '<' was expecting a DateTime received Number.










    share|improve this question
























      up vote
      2
      down vote

      favorite









      up vote
      2
      down vote

      favorite











      I'm trying to add a line to a set of existing validation rules so they only apply to opportunities created prior to a fixed date. Let's say 10/31/2018. I thought it would be pretty straightforward as



      CreatedDate < 10/31/2018



      So the entire rule would read:



      ISPICKVAL ( StageName, "Demo")&&



      Clinical_Buyer__c = FALSE&&



      CreatedDate < 10/31/2018



      I keep getting the error that the '<' was expecting a DateTime received Number.










      share|improve this question













      I'm trying to add a line to a set of existing validation rules so they only apply to opportunities created prior to a fixed date. Let's say 10/31/2018. I thought it would be pretty straightforward as



      CreatedDate < 10/31/2018



      So the entire rule would read:



      ISPICKVAL ( StageName, "Demo")&&



      Clinical_Buyer__c = FALSE&&



      CreatedDate < 10/31/2018



      I keep getting the error that the '<' was expecting a DateTime received Number.







      formula validation validation-rule






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Nov 19 at 21:40









      Devin Pearman

      228




      228






















          1 Answer
          1






          active

          oldest

          votes

















          up vote
          6
          down vote



          accepted










          Unlike SOQL, formulas don't accept date literals. You'll need to construct your Date values using either the DATE() function :




          The DATE() function returns a Date value, given a year, month, and day. Numerical Y/M/D values and the YEAR(), MONTH(), and DAY() functions are valid parameters for DATE(). For example DATE( 2013, 6, 1 ) returns June 1, 2013




          or the DATEVALUE() function, with a text parameter in ISO format:




          You can also convert text to a Date so you can use the string value with your other Date fields and formulas. You’ll want your text to be formatted as “YYYY-MM-DD”. Use this formula to return the Date value:



          DATEVALUE( "YYYY-MM-DD" )




          If you want to compare the DateTime CreatedDate to a Date value, you can convert the field value with DATEVALUE():



          DATEVALUE(CreatedDate) < DATEVALUE("2018-10-31") 





          share|improve this answer























          • I've attempted to use the DATE() function, but still getting an error: Incorrect parameter type for operator '<'. Expected DateTime, received Date I had entered: CreatedDate < DATE(2018,10,1)
            – Devin Pearman
            Nov 19 at 22:30












          • You can convert the DateTime to a Date with the DATEVALUE() function, too.
            – David Reed
            Nov 19 at 22:37










          • I'm not 100% on what you're meaning by converting to a DateTime, when this is all in a validation rule, there's got to be something I'm not understanding. I've tried adding a DATEVALUE but that doesn't seem to work either, perhaps I'm not using the correct syntax: ISPICKVAL ( StageName, "Negotiation")&& Clinical_Acceptance__c = FALSE&& CreatedDate < DATEVALUE("2018-10-31") The error I'm receiving: "Error: Incorrect parameter type for operator '<'. Expected DateTime, received Date"
            – Devin Pearman
            Nov 19 at 22:44












          • thank you so much, this worked perfectly!
            – Devin Pearman
            Nov 20 at 15:47











          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',
          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%2f239896%2fvalidation-rule-created-date-fixed-date%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes








          up vote
          6
          down vote



          accepted










          Unlike SOQL, formulas don't accept date literals. You'll need to construct your Date values using either the DATE() function :




          The DATE() function returns a Date value, given a year, month, and day. Numerical Y/M/D values and the YEAR(), MONTH(), and DAY() functions are valid parameters for DATE(). For example DATE( 2013, 6, 1 ) returns June 1, 2013




          or the DATEVALUE() function, with a text parameter in ISO format:




          You can also convert text to a Date so you can use the string value with your other Date fields and formulas. You’ll want your text to be formatted as “YYYY-MM-DD”. Use this formula to return the Date value:



          DATEVALUE( "YYYY-MM-DD" )




          If you want to compare the DateTime CreatedDate to a Date value, you can convert the field value with DATEVALUE():



          DATEVALUE(CreatedDate) < DATEVALUE("2018-10-31") 





          share|improve this answer























          • I've attempted to use the DATE() function, but still getting an error: Incorrect parameter type for operator '<'. Expected DateTime, received Date I had entered: CreatedDate < DATE(2018,10,1)
            – Devin Pearman
            Nov 19 at 22:30












          • You can convert the DateTime to a Date with the DATEVALUE() function, too.
            – David Reed
            Nov 19 at 22:37










          • I'm not 100% on what you're meaning by converting to a DateTime, when this is all in a validation rule, there's got to be something I'm not understanding. I've tried adding a DATEVALUE but that doesn't seem to work either, perhaps I'm not using the correct syntax: ISPICKVAL ( StageName, "Negotiation")&& Clinical_Acceptance__c = FALSE&& CreatedDate < DATEVALUE("2018-10-31") The error I'm receiving: "Error: Incorrect parameter type for operator '<'. Expected DateTime, received Date"
            – Devin Pearman
            Nov 19 at 22:44












          • thank you so much, this worked perfectly!
            – Devin Pearman
            Nov 20 at 15:47















          up vote
          6
          down vote



          accepted










          Unlike SOQL, formulas don't accept date literals. You'll need to construct your Date values using either the DATE() function :




          The DATE() function returns a Date value, given a year, month, and day. Numerical Y/M/D values and the YEAR(), MONTH(), and DAY() functions are valid parameters for DATE(). For example DATE( 2013, 6, 1 ) returns June 1, 2013




          or the DATEVALUE() function, with a text parameter in ISO format:




          You can also convert text to a Date so you can use the string value with your other Date fields and formulas. You’ll want your text to be formatted as “YYYY-MM-DD”. Use this formula to return the Date value:



          DATEVALUE( "YYYY-MM-DD" )




          If you want to compare the DateTime CreatedDate to a Date value, you can convert the field value with DATEVALUE():



          DATEVALUE(CreatedDate) < DATEVALUE("2018-10-31") 





          share|improve this answer























          • I've attempted to use the DATE() function, but still getting an error: Incorrect parameter type for operator '<'. Expected DateTime, received Date I had entered: CreatedDate < DATE(2018,10,1)
            – Devin Pearman
            Nov 19 at 22:30












          • You can convert the DateTime to a Date with the DATEVALUE() function, too.
            – David Reed
            Nov 19 at 22:37










          • I'm not 100% on what you're meaning by converting to a DateTime, when this is all in a validation rule, there's got to be something I'm not understanding. I've tried adding a DATEVALUE but that doesn't seem to work either, perhaps I'm not using the correct syntax: ISPICKVAL ( StageName, "Negotiation")&& Clinical_Acceptance__c = FALSE&& CreatedDate < DATEVALUE("2018-10-31") The error I'm receiving: "Error: Incorrect parameter type for operator '<'. Expected DateTime, received Date"
            – Devin Pearman
            Nov 19 at 22:44












          • thank you so much, this worked perfectly!
            – Devin Pearman
            Nov 20 at 15:47













          up vote
          6
          down vote



          accepted







          up vote
          6
          down vote



          accepted






          Unlike SOQL, formulas don't accept date literals. You'll need to construct your Date values using either the DATE() function :




          The DATE() function returns a Date value, given a year, month, and day. Numerical Y/M/D values and the YEAR(), MONTH(), and DAY() functions are valid parameters for DATE(). For example DATE( 2013, 6, 1 ) returns June 1, 2013




          or the DATEVALUE() function, with a text parameter in ISO format:




          You can also convert text to a Date so you can use the string value with your other Date fields and formulas. You’ll want your text to be formatted as “YYYY-MM-DD”. Use this formula to return the Date value:



          DATEVALUE( "YYYY-MM-DD" )




          If you want to compare the DateTime CreatedDate to a Date value, you can convert the field value with DATEVALUE():



          DATEVALUE(CreatedDate) < DATEVALUE("2018-10-31") 





          share|improve this answer














          Unlike SOQL, formulas don't accept date literals. You'll need to construct your Date values using either the DATE() function :




          The DATE() function returns a Date value, given a year, month, and day. Numerical Y/M/D values and the YEAR(), MONTH(), and DAY() functions are valid parameters for DATE(). For example DATE( 2013, 6, 1 ) returns June 1, 2013




          or the DATEVALUE() function, with a text parameter in ISO format:




          You can also convert text to a Date so you can use the string value with your other Date fields and formulas. You’ll want your text to be formatted as “YYYY-MM-DD”. Use this formula to return the Date value:



          DATEVALUE( "YYYY-MM-DD" )




          If you want to compare the DateTime CreatedDate to a Date value, you can convert the field value with DATEVALUE():



          DATEVALUE(CreatedDate) < DATEVALUE("2018-10-31") 






          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Nov 19 at 22:45

























          answered Nov 19 at 21:47









          David Reed

          26.7k51745




          26.7k51745












          • I've attempted to use the DATE() function, but still getting an error: Incorrect parameter type for operator '<'. Expected DateTime, received Date I had entered: CreatedDate < DATE(2018,10,1)
            – Devin Pearman
            Nov 19 at 22:30












          • You can convert the DateTime to a Date with the DATEVALUE() function, too.
            – David Reed
            Nov 19 at 22:37










          • I'm not 100% on what you're meaning by converting to a DateTime, when this is all in a validation rule, there's got to be something I'm not understanding. I've tried adding a DATEVALUE but that doesn't seem to work either, perhaps I'm not using the correct syntax: ISPICKVAL ( StageName, "Negotiation")&& Clinical_Acceptance__c = FALSE&& CreatedDate < DATEVALUE("2018-10-31") The error I'm receiving: "Error: Incorrect parameter type for operator '<'. Expected DateTime, received Date"
            – Devin Pearman
            Nov 19 at 22:44












          • thank you so much, this worked perfectly!
            – Devin Pearman
            Nov 20 at 15:47


















          • I've attempted to use the DATE() function, but still getting an error: Incorrect parameter type for operator '<'. Expected DateTime, received Date I had entered: CreatedDate < DATE(2018,10,1)
            – Devin Pearman
            Nov 19 at 22:30












          • You can convert the DateTime to a Date with the DATEVALUE() function, too.
            – David Reed
            Nov 19 at 22:37










          • I'm not 100% on what you're meaning by converting to a DateTime, when this is all in a validation rule, there's got to be something I'm not understanding. I've tried adding a DATEVALUE but that doesn't seem to work either, perhaps I'm not using the correct syntax: ISPICKVAL ( StageName, "Negotiation")&& Clinical_Acceptance__c = FALSE&& CreatedDate < DATEVALUE("2018-10-31") The error I'm receiving: "Error: Incorrect parameter type for operator '<'. Expected DateTime, received Date"
            – Devin Pearman
            Nov 19 at 22:44












          • thank you so much, this worked perfectly!
            – Devin Pearman
            Nov 20 at 15:47
















          I've attempted to use the DATE() function, but still getting an error: Incorrect parameter type for operator '<'. Expected DateTime, received Date I had entered: CreatedDate < DATE(2018,10,1)
          – Devin Pearman
          Nov 19 at 22:30






          I've attempted to use the DATE() function, but still getting an error: Incorrect parameter type for operator '<'. Expected DateTime, received Date I had entered: CreatedDate < DATE(2018,10,1)
          – Devin Pearman
          Nov 19 at 22:30














          You can convert the DateTime to a Date with the DATEVALUE() function, too.
          – David Reed
          Nov 19 at 22:37




          You can convert the DateTime to a Date with the DATEVALUE() function, too.
          – David Reed
          Nov 19 at 22:37












          I'm not 100% on what you're meaning by converting to a DateTime, when this is all in a validation rule, there's got to be something I'm not understanding. I've tried adding a DATEVALUE but that doesn't seem to work either, perhaps I'm not using the correct syntax: ISPICKVAL ( StageName, "Negotiation")&& Clinical_Acceptance__c = FALSE&& CreatedDate < DATEVALUE("2018-10-31") The error I'm receiving: "Error: Incorrect parameter type for operator '<'. Expected DateTime, received Date"
          – Devin Pearman
          Nov 19 at 22:44






          I'm not 100% on what you're meaning by converting to a DateTime, when this is all in a validation rule, there's got to be something I'm not understanding. I've tried adding a DATEVALUE but that doesn't seem to work either, perhaps I'm not using the correct syntax: ISPICKVAL ( StageName, "Negotiation")&& Clinical_Acceptance__c = FALSE&& CreatedDate < DATEVALUE("2018-10-31") The error I'm receiving: "Error: Incorrect parameter type for operator '<'. Expected DateTime, received Date"
          – Devin Pearman
          Nov 19 at 22:44














          thank you so much, this worked perfectly!
          – Devin Pearman
          Nov 20 at 15:47




          thank you so much, this worked perfectly!
          – Devin Pearman
          Nov 20 at 15:47


















          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.





          Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


          Please pay close attention to the following guidance:


          • 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%2f239896%2fvalidation-rule-created-date-fixed-date%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

          Plaza Victoria

          In PowerPoint, is there a keyboard shortcut for bulleted / numbered list?

          How to put 3 figures in Latex with 2 figures side by side and 1 below these side by side images but in...