+ Start a Discussion
kevinjia1984kevinjia1984 

How to get today's date in a date type field?

Hi Guys,

 

I am a newbie. Just want to know how to make a date type field equals to today's date. I have tried objectName.fieldName= today(). but it seems wrong. 

Best Answer chosen by Admin (Salesforce Developers) 
*werewolf**werewolf*

Well you can do that by creating a field of type Formula, then choosing the Date type on the following screen.  When it comes time to input the formula itself, that's when you can input

 

TODAY()

 

Finally put the field on one or more page layouts, and voila.

All Answers

*werewolf**werewolf*

Do you mean you want to set that field via the API, or just show it within the Salesforce.com web app?

kevinjia1984kevinjia1984

I just want to show it within salesforce. Put it in a method with in a Apex class

*werewolf**werewolf*

Well you can do that by creating a field of type Formula, then choosing the Date type on the following screen.  When it comes time to input the formula itself, that's when you can input

 

TODAY()

 

Finally put the field on one or more page layouts, and voila.

This was selected as the best answer