0

I am using the format function in SOQL to format a date to DD/MM/YYYY when retrieved.

I can see the formattedCreatedDate in the debug logs and it is displaying correctly but cant reference it in a VF page. Not sure why?

My SOQL is:

consultancyOpps = [Select Id, Name, CreatedDate,FORMAT(CreatedDate) formattedCreatedDate from Opportunity where RecordType.Name = 'Consultancy ORDER BY CreatedDate DESC];

My VF page is trying to fetch {!consultancyOpps.formattedCreatedDate} but I get an error. I can display the other fields fine (Id, Name).

Not sure what I need to do to be able to display the formattedCreatedDate

3
  • Thanks Phil, I did have this in place but can't get it to work with moment.js dataTable sorting for the dates, which is why I wanted to retrieve them in a format moment.js would recognise.
    – Joe Hayes
    Commented Nov 13, 2019 at 12:09
  • 2
    You can explicitly define the format using the <apex:outputText value="{0,date,dd MMM YYYY h:mm a}"> <apex:param value="{c.CreatedDate}"/> </apex:outputText> markup approach... you just have to define the formatting to be applied in that pattern ("dd MMM YYYY h:mm a" in this example).
    – Phil W
    Commented Nov 13, 2019 at 12:12
  • Thanks Phil, I'll give it another try
    – Joe Hayes
    Commented Nov 13, 2019 at 12:16

0

Browse other questions tagged .