web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

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

I have the same question (0)
  • jdecottignies Profile Picture
    217 on at

    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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > Small and medium business | Business Central, NAV, RMS

#1
OussamaSabbouh Profile Picture

OussamaSabbouh 2,577

#2
YUN ZHU Profile Picture

YUN ZHU 888 Super User 2025 Season 2

#3
Jainam M. Kothari Profile Picture

Jainam M. Kothari 778 Super User 2025 Season 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans