+ Start a Discussion
Mit PatelMit Patel 

soql query help

Hiii everyone.


I have 2 input date and time field. 

for ex.


Startdate 1/4/2013 abd time is 1:30pm this is input i will convet date time field and store one datetime field so my new startdatetime field is now like : 1/4/2013 1:30. same as i create enddatetiem.


Now i need to write query on evetn object and in where condition i need to comper this 2 startedate and enddate field with standared startdate and enddate field.


my doubt is.


my input startdatetime is 1/4/2013 : 1.30

              enddatetime is  5/4/2013 : 2.30


so i need those record in event object where every day  satrtdate and enddate beetween 1:30 to 2:30 time related rocord.


i mean in there is one record is 1/4/2013 : 1:31 so this is i want but 1/4/2013 2:35 related recoed i dont want.

same as 2/4/2013 : 1:30 to  2/4/2013 2:30 related recoed only i  want.

             3/4/2013 : 1:30 to  3/4/2013 2:30 related recoed only i  want. upto 5/4/2013.


plz reply quick. its urgent.




Best Answer chosen by Admin (Salesforce Developers) 



the docs on SOQL say under field expression

fieldName The name of a field in the specified object. Use of single or double quotes around the name will result in an error. You must have at least read-level permissions to the field. It can be any field—it does not need to be a field in thefieldList. comparisonOperator See 


Comparison Operators for a list of valid operators.


value A value used to compare with the value in fieldName. You must supply a value whose data type matches the field type of the specified field. You must supply a native value—other field names or calculations are not permitted. For date values, use the formatting listed in Date Formats and Date Literals. If quotes are required (for example, they are not for dates and numbers), use single quotes. Double quotes result in an error.



If you need to compare 2 fields like that, then you'd need to make a formula field does the comparision or returns the difference between the 2, so that in SOQL you can compare the formula result against a literal value.