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...
Suggested Answer

The value can't be evaluated into type Time.

(0) ShareShare
ReportReport
Posted on by 891
So, I have a datetime column called [Starting Time] in an SQL Server Dynamics NAV (On-Prem) database. It appears to have a default value of '1753-01-01 00:00:00.000'. If a time is assigned to the field in Business Central the date part in the database advances one year (e.g.) '1754-01-01 15:07:27.007'
I've created an AL Extension in VS Code containing an API Page in which one of the fields defined is the aforementioned [Starting Time] (see below):
field(StartingTime; "Starting Time") { }
When I hover the mouse cursor over this field in VS Code it reports: '(field) "Starting Time": Time'
I've then downloaded the XML metadata from Dynamics NAV (see section below). Notice, it has defined the field as "Edm.String" ?
<Property Name=""StartingTime"" Type=""Edm.String"">
  <Annotation Term=""NAV.LabelId"" String=""StartingTime"" />
  <Annotation Term=""NAV.NavType"">
    <EnumMember>NAV.NavType/String</EnumMember>
  </Annotation>
</Property>
I've then create an OData connected service in a C# .NET Core 2.2 Web App in Visual Studio 2019.
See auto-generated code below:-
/// <summary>
/// There are no comments for Property StartingTime in the schema.
/// </summary>
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "2.6.0")]
public string StartingTime
{
    get
    {
        return this._StartingTime;
    }
    set
    {
        this.OnStartingTimeChanging(value);
        this._StartingTime = value;
        this.OnStartingTimeChanged();
    }
}
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "2.6.0")]
private string _StartingTime;
partial void OnStartingTimeChanging(string value);
partial void OnStartingTimeChanged();
I have a Razor View as below, which displays a nice TimePicker control:-
@Html.EditorFor(model => Model.ServiceHeader.StartingTime, new { htmlAttributes = new { @class = "form-control", @type = "time" } })
The value chosen is returned to the Controller (e.g.) "01:00".
I populate the relevant object's properties and call the functions below to update the database via the OData interface:-
_context.AttachTo("API_Service_Header", lobjSH, "*");
_context.UpdateObject(lobjSH);
await _context.SaveChangesAsync(SaveChangesOptions.None);
... And I get the following error:-
{"error":{"code":"Application_EvaluateException","message":"The value \"1754-01-01 01:00:00\" can't be evaluated into type Time."}}
By the way I've tried formatting the value as just a time (e.g.) "01:00" and I've tried formatting it as full date (e.g.) "1754-01-01 01:00:00" - Same error.
Any help would be greatly appreciated?
I have the same question (0)
  • Suggested answer
    keoma Profile Picture
    32,729 on at

    edm.string seems to be wrong, should be edm.timeofday.

    set a valid time value in that field and try again.

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 3,226

#2
Jainam M. Kothari Profile Picture

Jainam M. Kothari 2,047 Super User 2025 Season 2

#3
YUN ZHU Profile Picture

YUN ZHU 1,257 Super User 2025 Season 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans