+ Start a Discussion
AmanAman 

query BirthDate in SOQL

 

I have two <apex:inputText> tags on VF pages  which receives Birthdate and have Jquery Datepicker.

<apex:inputText value="{!BirthDate}"/>

and 

<apex:inputText value="{!BirthDateTo}"/>

When user select date in both fields.

 

I want to pick results through SOQL in from range.

like.

select id from object__c where dob>= birthdate and dob<=birthdateto

 

But the date type of dob in object is of type Text instead of Date.

 

Is anyone help me to how to query the data in range if i have the datatype of dob in text.

Please help me.

 

SrikanthKuruvaSrikanthKuruva

Modify the dob field datatype on the object__c to DateTime or Date

AmanAman

 

We can not change our data type from tex to datetime or date.

SrikanthKuruvaSrikanthKuruva

what is max no.of records the object__c can have?

IbigfootIbigfoot
SrikanthKuruvaSrikanthKuruva

Date.parse(String) does not work in this scenario... you can give it a try...

AmanAman

If i use Date.parse(String) it converts string to date but when i use that date in our dynamic query

 

my date type is of type text and and on other hand my input is in the form of date.

 

force.com shows error

 

and i have near about 500 records and displaying it through pagination.

SrikanthKuruvaSrikanthKuruva

what is the total no.of records in the objec__c?

AmanAman

near about 500

SrikanthKuruvaSrikanthKuruva

then you can do the following

1)query all the 500 records in to a list

2) for each record 

{

//check if the date.parse(string date field on record) satisfies your criteria

}

3)if it satisfies add it to a new list else ignore it.

 

now you have all the records satisfying your criteria in a new list. return this new list to the vf page.