Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 563757
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T12:41:37+00:00 2026-05-13T12:41:37+00:00

Is there a way one can represent a time only value in .NET without

  • 0

Is there a way one can represent a time only value in .NET without the date? For example, indicating the opening time of a shop?

TimeSpan indicates a range, whereas I only want to store a time value. Using DateTime to indicate this would result in new DateTime(1,1,1,8,30,0) which is not really desirable.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T12:41:38+00:00Added an answer on May 13, 2026 at 12:41 pm

    As others have said, you can use a DateTime and ignore the date, or use a TimeSpan. Personally I’m not keen on either of these solutions, as neither type really reflects the concept you’re trying to represent – I regard the date/time types in .NET as somewhat on the sparse side which is one of the reasons I started Noda Time. In Noda Time, you can use the LocalTime type to represent a time of day.

    Note that as of .NET 6, there are TimeOnly and DateOnly types which are roughly equivalent to Noda Time’s LocalTime and LocalDate types.

    One thing to consider: the time of day is not necessarily the length of time since midnight on the same day…

    (As another aside, if you’re also wanting to represent a closing time of a shop, you may find that you want to represent 24:00, i.e. the time at the end of the day. Most date/time APIs – including Noda Time – don’t allow that to be represented as a time-of-day value.)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is there a way I can get the names of the areas in an
In Haskell, in order to represent the literal string \ , one would normally
I'm wondering if a number is represented one way in a floating point representation,
I need to represent single precision numbers as text in a way that won't
I want to represent documents in a database. There are several different types of
I am working on a project in C#.NET using the .NET framework version 3.5.
There are lof of difference between Linq to Sql and Entity framework like Linq
I'm trying to load some decimal values from a file but I can't work
A device contains an array of locations, some of which contain values that we
Assume that the data X has size 1000 *1000. X is displayed using the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.