Skip to main content
added 322 characters in body
Source Link
James Hill
  • 1.3k
  • 13
  • 21

Nothing simple exists that I'm aware of.

However, check out the useful advanced formulae page: http://login.salesforce.com/help/doc/en/useful_advanced_formulas.htm

In particular, this has a formula for calculating the day of the week as a number (0 = Sunday...6=Sunday).

MOD(entry_date__c - DATE(1900, 1, 7), 7)

The above will give you Entry Date's day of the week. To get Sunday, you should be able to subtract the result of that from the Entry Date

DATE(
    YEAR(Entry_Date__c),
    Month(Entry_Date__c),
    DAY(Entry_Date__c)-MOD(entry_date__c - DATE(1900, 1, 7), 7))

Though you would need to add some complexity to this to handle the start of a month/year.

Edit:As @TomLogic points out below, you may be able to avoid using the DATE function and having to add complexity to handle start of month/year issues by subtracting the result of the Mod operation from the Date directly (though I've not yet tested it!)

Entry_Date__c - MOD(entry_date__c - DATE(1900, 1, 7), 7))

Nothing simple exists that I'm aware of.

However, check out the useful advanced formulae page: http://login.salesforce.com/help/doc/en/useful_advanced_formulas.htm

In particular, this has a formula for calculating the day of the week as a number (0 = Sunday...6=Sunday).

MOD(entry_date__c - DATE(1900, 1, 7), 7)

The above will give you Entry Date's day of the week. To get Sunday, you should be able to subtract the result of that from the Entry Date

DATE(
    YEAR(Entry_Date__c),
    Month(Entry_Date__c),
    DAY(Entry_Date__c)-MOD(entry_date__c - DATE(1900, 1, 7), 7))

Though you would need to add some complexity to this to handle the start of a month/year.

Nothing simple exists that I'm aware of.

However, check out the useful advanced formulae page: http://login.salesforce.com/help/doc/en/useful_advanced_formulas.htm

In particular, this has a formula for calculating the day of the week as a number (0 = Sunday...6=Sunday).

MOD(entry_date__c - DATE(1900, 1, 7), 7)

The above will give you Entry Date's day of the week. To get Sunday, you should be able to subtract the result of that from the Entry Date

DATE(
    YEAR(Entry_Date__c),
    Month(Entry_Date__c),
    DAY(Entry_Date__c)-MOD(entry_date__c - DATE(1900, 1, 7), 7))

Though you would need to add some complexity to this to handle the start of a month/year.

Edit:As @TomLogic points out below, you may be able to avoid using the DATE function and having to add complexity to handle start of month/year issues by subtracting the result of the Mod operation from the Date directly (though I've not yet tested it!)

Entry_Date__c - MOD(entry_date__c - DATE(1900, 1, 7), 7))
Source Link
James Hill
  • 1.3k
  • 13
  • 21

Nothing simple exists that I'm aware of.

However, check out the useful advanced formulae page: http://login.salesforce.com/help/doc/en/useful_advanced_formulas.htm

In particular, this has a formula for calculating the day of the week as a number (0 = Sunday...6=Sunday).

MOD(entry_date__c - DATE(1900, 1, 7), 7)

The above will give you Entry Date's day of the week. To get Sunday, you should be able to subtract the result of that from the Entry Date

DATE(
    YEAR(Entry_Date__c),
    Month(Entry_Date__c),
    DAY(Entry_Date__c)-MOD(entry_date__c - DATE(1900, 1, 7), 7))

Though you would need to add some complexity to this to handle the start of a month/year.