Skip to main content

Notifications

Community site session details

Community site session details

Session Id :
Small and medium business | Business Central, N...
Unanswered

[DateFormula] Handle DateFormula translation in code ?

(0) ShareShare
ReportReport
Posted on by 217

Hi,

I think I'm struggling with an issue that exist for a long time but I try anyway.

The context is a setup table containing some DateFormula fields.

This field is used with a CalcDate() at some point in my code.

When the language is in english, the CalcDate is performed succesfully.

If the language is in French, I have this error:

pastedimage1601370521554v1.png

"Date Formula -2S must contain a Time Unit. Time unit can be J, JS, S, M, T or A, C..."

Please note that the 'S' I provided is listed in the error as a valid time unit.

In my code, if I hardcode CalcDate('<-2W>', refDate); there is no problem.

It seems the system is not translating the date formula value in english when we are in another language. But tell me if i'm wrong.

My question:

Is there an easy "universal" way to use date formula in the code? Or do I have to translate the formula by myself according to the system language ?

Thanks for any help

  • jdecottignies Profile Picture
    217 on at
    RE: [DateFormula] Handle DateFormula translation in code ?

    I find a solution:

    I've set the language to ENU for this process:

    Language := 1033;

    CalcDate(....)

    Hope it will help ..!

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Jainam Kothari – Community Spotlight

We are honored to recognize Jainam Kothari as our June 2025 Community…

Congratulations to the May Top 10 Community Leaders!

These are the community rock stars!

Announcing the Engage with the Community forum!

This forum is your space to connect, share, and grow!

Leaderboard >

Featured topics

Product updates

Dynamics 365 release plans