Skip to main content

Notifications

Announcements

No record found.

Small and medium business | Business Central, N...
Suggested answer

Converting DateTime to UNIX Timestamp in AL/Business Central - Strange behavior with Decimal to String conversion

(0) ShareShare
ReportReport
Posted on by 20

Greetings Community -

I found an online blog (don't remember the URL) which helped me get the function below to convert DateTime format to UNIX Format.

The output of the below function is accurate, however, when I get the Decimal as a return value of the function and try to convert it to text, the additional spaces show up between the digits, strangely enough

After trying DELSTR(String,'='), the spaces don't go away. I am probably missing something, can anyone please assist?

pastedimage1674571989099v1.png

pastedimage1674572018260v2.png

ajkauffmann 

  • Suggested answer
    ajkauffmann Profile Picture
    ajkauffmann 117 on at
    RE: Converting DateTime to UNIX Timestamp in AL/Business Central - Strange behavior with Decimal to String conversion

    The Format command includes all signs by default. In your case the thousand delimiter is probably a space.

    The best option is to use an extra parameter to indicate how the decimal should be formatted. The standard XML format will work here:

    Format(UnixDecimal, 0, 9);

    Then you don't need to remove any character afterward.

  • rtechc Profile Picture
    rtechc 20 on at
    RE: Converting DateTime to UNIX Timestamp in AL/Business Central - Strange behavior with Decimal to String conversion

    Hi Daniel - Thanks for the suggestion. I tried both these formats of DELCHR, but it does not seem to work, same output. Moreover, when I try to find the position/occurrence of a blank character in the string using STRPOS, it gives me a 0 (no blank substrings exist)

    I then tried converting my string output into ASCII, and there are ASCII Blank spaces in between. I am really confused as to what is happening

    pastedimage1674612309339v1.png

    Do you know what is happening?

    String Pasted from the Debugger: 1 674 610 728 407

  • Suggested answer
    DAnny3211 Profile Picture
    DAnny3211 9,272 Super User 2024 Season 1 on at
    RE: Converting DateTime to UNIX Timestamp in AL/Business Central - Strange behavior with Decimal to String conversion

    hi

    try this

    DELCHR(ResourceUpdAPIPArams,'=',' ')

    DAniele

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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Verified Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,391 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,445 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans