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 :
Microsoft Dynamics NAV (Archived)

Concatenate a Date and Text into a Text Variable

(1) ShareShare
ReportReport
Posted on by 2

This is what I want to do:

PeriodText :=  'As at: ', EndDate

This is what PeriodText is:

PeriodText is a Text DataType and has a length of 25. 

This is my error:

Error: Type conversion is not possible because 1 of the operators contains an invalid type. Text := Date

Is there a way to convert, cast, concatenate the date type into/with the string and then assign it to the text datatype? I would accept the possibility of only assigning a type casted EndDate to it. 

Also, I cannot change PeriodText to a date type because it is used in other locations outside of my IF statement. 

*This post is locked for comments

I have the same question (0)
  • Verified answer
    Suresh Kulla Profile Picture
    50,243 Super User 2025 Season 2 on at

    Edward

    Try this

    PeriodText := 'As at: ' + FORMAT(EndDate);

    Just FYI FORMAT function is used to convert other data types into text.

  • Verified answer
    mmv Profile Picture
    11,471 on at

    Hi,

    As you are trying to concatenate Date datatype and Text, you are getting the error.  As mentioned by Suresh, you need to use the FORMAT function while concatenating with different datatypes with text.

  • Verified answer
    Tharanga Chandrasekara Profile Picture
    23,118 on at

    Function you are looking for is FORMAT. FORMAT function Formats a value into a string.

    To learn more about format function refer this link. 

    As suresh mentioned you can use following code line.

    PeriodText := 'As at: ' + FORMAT(EndDate);

  • Verified answer
    edwardl Profile Picture
    2 on at

    Here is the code that I settled on:

    IF "Acc. Schedule Line".GETRANGEMIN("Date Filter") = "Acc. Schedule Line".GETRANGEMAX("Date Filter") THEN

     PeriodText :=  'As at: ' + FORMAT(EndDate)

    ELSE PeriodText :=

     AccSchedManagement.BuildFinPerDescription(

       AccScheduleName."Financial Period Description",StartDate,EndDate);

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 > 🔒一 Microsoft Dynamics NAV (Archived)

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans