You need to sign in to do that
Don't have an account?
anuraj
Search date
Hi
In this code I have a text box where i have to enter the date and the code is for searching the date from the object.
The code is
Date myDate = date.valueOf(StartDate);
if (!StartDate.equals(''))
soql += ' and Start_Date__c LIKE (\''+myDate+'\')';
if the format is in year-month-date then the error
ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.ERROR, 'Ooops!'));
and if any other format is used the the error is :
System.TypeException: Invalid date: 2011-16-9
thanks
Anuraj
This will look for the string representation of the date in the field - is that what you are looking for, i.e. is Start_Date__c a text field?
Can you explain a little more about what you are trying to achieve?
Hi bob
Yes this is looking for text. I converted it to date type. As this is a date field I have removed the ' ' and done it as
but now the problem is when i changed it to date it is in
datetime format
eg : 2011-09-20 00:00:00
and the code is showing error for this I used this code substring but not working
I run the query in Apex explore with out 2011-09-20 it is giving the result.
Now i want to remove time from the mydate value
please help me.
Thanks
Anuraj
So if I understand correctly, you have a text representation of a Date in the StartDate variable. That being the case, why are you converting it to a date and back again?
Hi bob
Leave this line of code
I have commended it.
I want to get only date from myDate
Now i am getting both date and time
thanks
Anuraj
What is the format of your startdate string? There may be no reason to go via a Date variable.
This is the code I wrote
I have not set any format it is takeing as year/month/day
thanks
Anuraj
What is the format of your date string?