I'm trying to pass a date from the querystring to a component on a visualforce page.

with a url like this: salesforce.com/apex/mypage?mydate=2013-05-30

I thought it would be as simple as this:

     <c:myComponent myDate="{!date.valueof($CurrentPage.parameters.mydate)}" />

but I'm getting an error when trying to save my visualforce page:

    Error: Unknown function date.valueof. Check spelling

What am I doing wrong? How do you pass a date to a component on a visualforce page via the querystring?


the date.valueof is an Apex syntax not visualforce. You could instead use

<c:myComponent myDate="{!datevalue($CurrentPage.parameters.mydate)}" />

This will work in parsing out the date in the format you have it. For instance ?mydate=2013-03-04 parses out for me as Mon Mar 04 00:00:00 GMT 2013

Or alternatively, if your component has a controller then you could pass the parameter through as a String and parse it there. This would give you some more control over dealing with badly formatted or missing data.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.