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

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Business Central forum

Cannot implicitly convert type date to datetime using al

(0) ShareShare
ReportReport
Posted on by 339

Dear expert ,

how to rectify in al "Cannot implicitly convert type date to datetime" using al 

"Posting Date" := valueenter."Posting Date";
Categories:
  • Suggested answer
    Stefano Demiliani Profile Picture
    37,172 Most Valuable Professional on at

    AL is not different than C/AL. 

    If you have a DATE field and you want to convert it to a DATETIME field, you need to use:

    YourDateTimeField := CREATEDATETIME(YourDateField,0T);  

  • SABIH Profile Picture
    339 on at

    Hello steffan

    showing as error please find below screenshot

    datetime.PNG

  • Suggested answer
    Stefano Demiliani Profile Picture
    37,172 Most Valuable Professional on at

    To create a DATETIME VALUE, you need a Date and a Time value. Here it's missing the TIME part. Check my post above, I've written:

    CREATEDATETIME(YourDateField,0T);  

    You need to write:

    YourDateTimeVariable := CreateDateTime("Posting Date",0T);

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

    Below is the function signature for "CREATEDATETIME". 

    DateTime := CREATEDATETIME(Date, Time)


    It takes 2 parameters in. However in your code you have only provided a one (Date). Since you do not have a time value, what you can do is pass 0T.

    "Posting Date" := CREATEDATETIME("Posting Date",0T);

    Please refer below UTL for more info : https://docs.microsoft.com/en-us/dynamics-nav/createdatetime-function--datetime-

  • jack07 Profile Picture
    25 on at

    Dear sir, I tried to do as follow

    pastedimage1681287794379v1.png

     when I run in my local, the system display message as below. how can I solve this?

    pastedimage1681287874381v2.png

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

November Spotlight Star - Khushbu Rajvi

Congratulations to a top community star!

Forum Structure Changes Coming on 11/8!

In our never-ending quest to help the Dynamics 365 Community members get answers faster …

Dynamics 365 Community Platform update – Oct 28

Welcome to the next edition of the Community Platform Update. This is a status …

Leaderboard > Business Central

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans