Skip to content

Blazor WASM : cannot convert from 'System.TimeSpan' to 'System.DateTime' #36427

@nssidhu

Description

@nssidhu

I am getting the following error

Severity	Code	Description	Project	File	Line	Suppression State
Error (active)	CS1503	Argument 1: cannot convert from 'System.TimeSpan' to 'System.DateTime'	XXXXXV6New.Client

I am storing Just the Time (like 9:00 AM") to indicate start time and stop time in Time(7) field of Azure SQL DB.

Dbcontext generates that field as
public TimeSpan StartTime { get; set; }

I am trying to bind this to input element

<input type="time" class="form-control time-control"    @bind:event="oninput"
                                   @bind="@_OrgLocation.StartTime" />

which is resulting into above mentioned error.

How do i resolve this issue ?

The idea is to store start and Stop time in database(just the Time part with AM/PM) like 9:00 am to 5:00 PM

Metadata

Metadata

Assignees

No one assigned

    Labels

    ✔️ Resolution: AnsweredResolved because the question asked by the original author has been answered.Status: Resolvedarea-blazorIncludes: Blazor, Razor Components

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions