You need to sign in to do that
Don't have an account?
EvertonSzekeres
Date Format Email Body
Hi,
I'm tryin to send a date field by email.
But my date is showing this MM/dd/yyyy.
And I am looking for this dd/MM/yyyy.
So I tried:
trigger Email_EventoFinalizado on Case (after insert, after update) { List<Case> CaseMap = new List<Case>(); for(Case c : Trigger.new){ IF(c.motivo__c == 'Último evento'){ Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage(); String[] toAddresses = new String[]{}; toAddresses.add('everton.gomes@cp7.com.br'); mail.setToAddresses(toAddresses); mail.setSubject(''+c.subject+''); Datetime myDT = Datetime.now(); String myDate = myDT.format('dd/MM/yyyy'); mail.setHtmlBody('<p>Turma: '+c.PIT__c+' - '+c.Nome_da_turma__c+'</p><p>Evento: '+c.Nome_do_evento__c+'</p><p>Data: '+myDT(c.Data_do_evento__c)+'</p><p>'+c.Description+'</p>'); Messaging.SendEmail(new Messaging.SingleEmailMessage[] {mail}); } } }
Error: Method does not exist or incorret signature : myDT(Date)
Thanks !
The error simply boils down to your syntax. If you need to format the date in that specified format, since Salesforce does not have a Date.format method that allows you to specify the format (it only returns it in context of the locale of the user), you will need to convert it to a date time first if you want this. Something like this should work:
All Answers
Hi ,
The alternative is :
Date d = Date.today();
String mydate = d.day()+'/'+d.month()+'/'+d.year();
It this post helps you then please mark it as a solution and don't forget to give me kudo's.
Thanks
Ashlekh
I'm puzzled here by the original code sample, the following works just fine
I´m trying to make this field "data_do_evento__c" showing like this "dd/MM/yyyy"
thanks,
The error simply boils down to your syntax. If you need to format the date in that specified format, since Salesforce does not have a Date.format method that allows you to specify the format (it only returns it in context of the locale of the user), you will need to convert it to a date time first if you want this. Something like this should work: