Skip to main content

Working with Dates in SFDC

·2 mins

Date fields are present everywhere in any CRM application, and SFDC is not an exception.

SFDC provides a number of ways in which you can work with date fields. There are more than a few things that you will find unique here, that look “oh so obvious” in hindsight.

Your date locale and time zone are set in My Settings > Language & Time Zone. You can change it any time you like to experience a “out of time zone” experience. I just made that up to show my literary skills.

While date fields allow only the date, date and time fields will accept the time (duh!). Valid dates are from 1/1/1700 and 31/12/4000, you have to look for another application. If you do see dates accepted beyond these in SFDC, don’t get too excited – you may be in just a different time zone, the above dates are in GMT.

Updates to Dates #

  1. You can of course choose dates the traditional way. Any date field will open a calendar when clicked, and the calendar popup looks like any other calendar control out there (which is a good thing by the way). You can ignore this and type in the dates, or you can pick the date from calendar
    working with dates in sfdc date control on fields
  1. You can enter text strings in date and SFDC understands what you meant.
    Valid strings are: today, tomorrow, Monday, Tuesday etc. Any weekday entered in this way will take the date today or later. This will work only if you use English language application.
    ![working with dates in salesforce updating dates](/uploads/2014/working-with-dates-in-salesforce-updating-dates.png)

  1. Type in only the day and month in any date field, and SFDC will put in the current year as the year.

  1. Type in only two digits for the year for any date, and the current century is prefixed. Don’t push it though – any year after 60 will be taken as in the previous century. Why 60? – well, why not?
     - 00 to 60 is 20th century (1900s), any other digits represent 21st century
     - 1/1/00 will become 1/1/2000
     - 1/1/59 will become 1/1/2059
     - 1/1/60 will become 1/1/1960
     - 1/1/99 will become 1/1/1999

Query Dates #

Querying on date through filters is as simple as querying on any other field.

You can use both date and time in querying against the Date/Time fields. The format is based on your locale, and you need to provide the time in HH:MM am/pm format.

For e.g. “21/10/2010 12:00 PM”

querying for dates in SFDC

Know of any other date tips? Comment and let me know.