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

Announcements

News and Announcements icon
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 911
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

Season of Sharing Community Challenge Launch!

Jump in, show your community spirit, and win prizes!

Women in Power Builds Momentum

Expanding mentorship, skilling, and AI innovation

Congratulations to the May Top 10 Community Leaders

These are the community rock stars!

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

#1
OussamaSabbouh Profile Picture

OussamaSabbouh 2,050 Super User 2026 Season 1

#2
YUN ZHU Profile Picture

YUN ZHU 1,441 Super User 2026 Season 1

#3
Grigorios Mavrogeorgis Profile Picture

Grigorios Mavrogeorgis 1,175 Super User 2026 Season 1

Last 30 days Overall leaderboard

Featured topics

Microsoft Training Manuals

Product updates

Dynamics 365 release plans