Skip to main content
5 votes
Accepted

How to find first Monday from given date?

The primary reason for that is that your formula is currently, literally being told to start from the first of the month /* v This right here */ DATE(...
Derek F's user avatar
  • 61.6k
4 votes
Accepted

Is this a bug in Apex DateTime.format?

Duh NO. Some more Googling reveals this answer from a different language: Difference between 'YYYY' and 'yyyy' in NSDateFormatter that can be summarized as: use yyyy not YYYY and that fixes the ...
Keith C's user avatar
  • 136k
3 votes
Accepted

Inserting a date field with soap API

JSON doesn't have a "native" date type. It has to be a string with quotes around it. Never write your own JSON, as it's easy to get wrong. I recommend using at minimum a combination of Map/...
sfdcfox's user avatar
  • 491k
3 votes
Accepted

LWC - render component onclick event

Date is an object, not a primitive, so this.date holds a reference, therefore its value doesn't change when you run setDate(). That's why the framework doesn't rerender it. Reactivity for Fields, ...
RubenDG's user avatar
  • 8,562
2 votes
Accepted

How do I subtract dates in LWC's JS?

Both today2 and renewalDate are string, so you're dividing a string by a number, that's why the result is NaN. You should use Date objects and leverage getTime() method that returns the number of ...
RubenDG's user avatar
  • 8,562
2 votes

Finding the average of dates using flow

This is not a complete solution, but I ran out of room in a comment. You could loop through the collection and assign two variables one for the count of records, and one for the sum of the dates, then ...
Dan Wooding's user avatar
  • 3,537
2 votes

How to determine start of week for a given locale in Apex

This isn't a solution to getting the start of day for any locale real time. It's a work around. I've written some ad-hoc code to get the start of week for each locale. From that, I can hard-code a ...
Ken's user avatar
  • 374
2 votes
Accepted

Format Date field to pass to OmniScript

Short answer: You need to cast it as a DateTime object, otherwise you won't be able to use the format(dateFormatString) method. The TestDate__c field used in the following example is a Date field. ...
DevelBase2's user avatar
2 votes

Change date format like dd/mm/yy

That's a valid date format. You don't need any processing converting to strings, splitting or anything. You can directly use Date.prototype.toLocaleString(). The format you need is actually India's ...
Sachin Hooda's user avatar
  • 1,632
1 vote

Update EndDate by calculating through start date +duration(picklist field)

Assuming that your updateWarrantyRecords() method is being called in a trigger context (from a trigger, from a handler in a trigger framework, etc...) Then I believe the main issue is the following ...
Derek F's user avatar
  • 61.6k
1 vote
Accepted

Method does not exist or incorrect signature: void date() from the type Date

Apex has two shortcuts, an overloaded + and - operator: sc.Cancellation_Request_Date__c = sc.Next_Payment_Date__c - 1; // Subtract a day Further, a Date is already a Date, which is why it has no date(...
sfdcfox's user avatar
  • 491k
1 vote

Creating a due date formula based on case types with different working days

The actual problem is missing commas. Sometimes the syntax checker gets confused by missing commas and thinks you missed a closing parenthesis instead. You are also missing a couple of inner CASE ...
Jason Clark's user avatar
  • 11.9k
1 vote

Creating a due date formula based on case types with different working days

You can try this: CASE(WEEKDAY(DATEVALUE(CreatedDate)), 1, CASE(Type, "Multiple queries", DATEVALUE(CreatedDate) + 12, "Legacy", DATEVALUE(CreatedDate) + 40, ...
Tushar Jadav's user avatar
  • 1,670
1 vote

Flow Formula Returning Null

Answer provided by cropredy (thank you!) DATEVALUE expects input to be yyyy-mm-dd I was doing "yyyy-dd-mm" and just needed to flip the month and day positioning. It was returning blank on ...
Snowlian's user avatar
1 vote

Setting Field Validation for Date Field Typo

If today's date is July 17th, 2023, then July 19th 2019 is not 4 years ago or more, so your validation rule is working as expected. If what you're trying to do is prevent that a record be saved if its ...
Brandon DeMatteis's user avatar
1 vote

how to convert date from yyyy-mm-dd to MMM d, yyyy

Dates can be coerced into Datetime, the "gotcha" to look out for here is that doing so means Salesforce treats it as if the Datetime is in the GMT (UTC +0) timezone. With that in mind, you ...
Derek F's user avatar
  • 61.6k
1 vote

Get time to close, instead of days

You can simply subtract one date/time/datetime from another (e.g. MyDateTime__c - MyOtherDateTime__c) This'll give you a result like 2.5376 where: The 2 (or rather, everything to the left of the ...
Derek F's user avatar
  • 61.6k
1 vote

How to calculate duration between two dates(in months and days) using formula field?

Here is a formula that returnes a text value in the next format: "xy year(s) xy month(s) xy day(s)". It calculates leap years as well. Example of use: Employment Duration TEXT( FLOOR(...
Marko Vujnovic's user avatar
1 vote

Calculate MAX between group of date fields

With the new-ish FROMUNIXTIME and UNIXTIMESTAMP functions, you can turn the date fields into numbers (unix time stamps), and feed those into the MAX function which returns a single value, and turn ...
gorav's user avatar
  • 4,527

Only top scored, non community-wiki answers of a minimum length are eligible