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
.
formula validation validation-rule
add a comment |
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
.
formula validation validation-rule
add a comment |
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
.
formula validation validation-rule
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
formula validation validation-rule
asked Nov 19 at 21:40
Devin Pearman
228
228
add a comment |
add a comment |
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")
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 theDATEVALUE()
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 aDATEVALUE
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
add a comment |
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")
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 theDATEVALUE()
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 aDATEVALUE
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
add a comment |
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")
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 theDATEVALUE()
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 aDATEVALUE
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
add a comment |
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")
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")
edited Nov 19 at 22:45
answered Nov 19 at 21:47
David Reed
26k51645
26k51645
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 theDATEVALUE()
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 aDATEVALUE
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
add a comment |
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 theDATEVALUE()
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 aDATEVALUE
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
add a comment |
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%2f239896%2fvalidation-rule-created-date-fixed-date%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