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 6214817
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T06:56:39+00:00 2026-05-24T06:56:39+00:00

I am trying to convert DateTime.MinValue to a DateTimeOffset value but am getting an

  • 0

I am trying to convert DateTime.MinValue to a DateTimeOffset value but am getting an ArgumentOutOfRange exception.

I was looking at the the MSDN article on implicit conversions of DateTime to DateTimeOffset and the Exception section states that I’ll receive this ArgumentOutOfRange exception when;

…
The Coordinated Universal Time (UTC) date and time that results from applying the offset is earlier than MinValue.
…

Why then does the following code throw the exception;

DateTime test = DateTime.MinValue;
DateTimeOffset dto = test;

Is it simply due to my timezone? I am in GMT +8, but my understanding of the above code is that test is created with an Unspecified kind.

I am working around the issue by simply testing for MinValue of my DateTime, and if so, then using DateTimeOffset.MinValue instead.

I am merely curious as to why my unspecified kind DateTime object causes the error.

  • 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-24T06:56:40+00:00Added an answer on May 24, 2026 at 6:56 am

    If you’re in GMT+8, then a local time of DateTime.MinValue corresponds to a UTC time earlier than DateTime.MinValue, hence the exception. From the documentation you referenced:

    If the value of the DateTime.Kind property is DateTimeKind.Local or DateTimeKind.Unspecified, the date and time of the DateTimeOffset object is set equal to dateTime, and its Offset property is set equal to the offset of the local system’s current time zone.

    So logically you would have a DateTime of MinValue with an Offset of 8 hours, but that means that the UTC date/time resulting from applying the offset is earlier than can be represented.

    (Don’t forget that you add an offset to UTC to get a local time, or subtract it from a local time to get UTC. In Noda Time we enforce this by using a types for each of Offset, LocalInstant and Instant, and only allow you to perform the appropriate operation…)

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

Sidebar

Related Questions

I am trying to convert a date to datetime but am getting errors. The
I am trying to convert varchar date value to datetime format. Showing error select
I am trying to convert the twitter post dates into datetime objects but for
I am trying to convert a mysql DATETIME into this format m/d/y but the
I am trying to convert my three parameters to a DATETIME but its not
I am trying to convert a string into date time format. DateTime.Parse(tempfrmBankDetails.dgvBankDetails.SelectedRows[0].Cells[PaymentDate].Value.ToString(),null); This is
i'm trying to convert following varchar date to datetime format but it doesn't work
I am trying to convert a value from a datetime field in a MySQL
I am trying to convert all DateTime values in a DataTable to strings. Here
I am trying to convert an access datetime field to a mysdl format, using

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.