function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
mark TMmark TM 

Trigger Help

Hi,

 

 Please help me to write a trigger for my requirement below,

 

I am creating a date field in my org which should automatically copy all the account created date to that date field.

 

Note :

 

Only the date should be copied and not the time which should happen for all ther exisiting records and new one.

 

Please kindly help me.

 

Thnks

Best Answer chosen by Admin (Salesforce Developers) 
Maros SitkoMaros Sitko
yes you can, set field as DATE and use this formula DATE( YEAR(CreatedDate), MONTH(CreatedDate), DAY(CreatedDate))

All Answers

Maros SitkoMaros Sitko
I do not know If I understand you: You want copy DATE from createdDate field to your custom field, which is Date not datetime.
If yes, why you want trigger, you can create formula or workflow(depend if you want have this field editable or not)
mark TMmark TM

Yes you are are right,

 

i want to copu only the date record from the standard field "Account created date" field to the new custom field of mine which is in date format (not the date/time)

 

how can i achieve this ,

1) if formula field hw can i use it to retrive only the date and not date time

 

 

Thanks

Maros SitkoMaros Sitko
yes you can, set field as DATE and use this formula DATE( YEAR(CreatedDate), MONTH(CreatedDate), DAY(CreatedDate))
This was selected as the best answer
mark TMmark TM
Thanks, It worked