© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
C#C
C#•2y ago•
12 replies
Cyclomatic

Passing DateOnly to controller

What's wrong with this snippet?

[HttpGet("ondate")]
public async Task<IActionResult> GetAppointmentsByDate([FromQuery]DateOnly date)
{
var appointments = await _appointmentDatabaseService.GetAppointmentByDate(date);
if (appointments != null)
{
return Ok(appointments);
}

return NotFound();
}

I'm using swagger, and the JSON looks like this:

{
"year": 2024,
"month": 5,
"day": 5,
"dayOfWeek": 1
}

yet I get the default(DateOnly) in my request
C# banner
C#Join
We are a programming server aimed at coders discussing everything related to C# (CSharp) and .NET.
61,871Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

✅ Passing data from controller to view
C#CC# / help
4y ago
✅ DateOnly.TryParse Vs DateOnly.TryParseExact use cases
C#CC# / help
11mo ago
❔ How to map dateonly and timeonly?
C#CC# / help
3y ago
DateTime format into DateOnly
C#CC# / help
4y ago