Skip to content

Date value out of range #80

Closed
Closed

Description

@asmaMdi

I'm using pyodata to get data from an url. Since the url contains a too far date in the past like "<d:StartDate>0001-01-01T00:00:00</d:StartDate>" I'm geting this error :"
value = datetime.datetime(1970, 1, 1, tzinfo=datetime.timezone.utc) + datetime.timedelta(milliseconds=int(value))
OverflowError: date value out of range"

Any help please

Asma

Activity

  1. filak-sap commented on Jan 29, 2020

    @filak-sap
    Contributor

    Thank you for taking the time to report the issue and sorry for the late reply.

    Can you please send me the data in JSON format? (Add $format=json to URL).

  2. asmaMdi commented on Feb 3, 2020

    @asmaMdi
    Author

    Hi,
    Thank you for your reply please find attached json file because I'm not allowed to put the url
    EmployeeData.zip

  3. filak-sap commented on Feb 6, 2020

    @filak-sap
    Contributor

    @asmaMdi I'm sorry but you provided XML. It's not enough to store it in *.json you need to download it as JSON.

    The following examples shows the difference:

    Example XML:
    https://services.odata.org/V2/Northwind/Northwind.svc/Employees

    Example JSON:
    https://services.odata.org/V2/Northwind/Northwind.svc/Employees?$format=json

  4. filak-sap commented on Feb 7, 2020

    @filak-sap
    Contributor

    I am really wondering what's the content of JSON because I tested pyodata with values for 0001-01-01T00:00:00 and also 9999-12-31T00:00:00 and both worked fine.

  5. asmaMdi commented on Feb 10, 2020

    @asmaMdi
    Author

    Hi,
    sorry for my delayed response. Please find attached file.
    EmployeeData.zip

  6. filak-sap commented on Feb 10, 2020

    @filak-sap
    Contributor

    @asmaMdi Thank you very much indeed. The minimal value in your data is represented by the number -62135769600000 which is 172799999miliseconds greater than the current lowest value PyOData can read (-62135596800000).

    If you subtract the date 0001-01-01T00:00:00 (your lowest value) from 1970-01-01T00:00:00 (OData base date) you get maximal value which -62135596800000.

    import datetime
    
    int((datetime.datetime(year=1, day=1, month=1) - datetime.datetime(year=1970, day=1, month=1)).total_seconds()) * 1000
    
    # result = -62135596800000

    If you subtract your lowest value from PyOData lowest value and add the result to the OData zero date, you get 1970-01-02T23:59:999000.

    import datetime
    
    datetime.datetime(year=1970, day=1, month=1) + datetime.timedelta(milliseconds=-62135596800001-(-62135769600000))
    
    # result = datetime.datetime(1970, 1, 2, 23, 59, 59, 999000)

    Can you, please, report the issue to your OData service provider?

    An excerpt of you data:

       {"__metadata":{"uri":"https://{REMOVED_HOST}/sap/byd/odata/cust/v1/odata_project/EmployeeEmployeeTypeCollection('0000000000011EE181BFC430CB1AAE84')",
       "type":"cust.EmployeeEmployeeType"},
       "ObjectID":"0000000000011EE181BFC430CB1AAE84",
       "ParentObjectID":"0000000000011EE181BFC41244F70E84",
       "EndDate":"\/Date(253402214400000)\/",
       "StartDate":"\/Date(-62135769600000)\/",
      "InternalEmployeeIndicator":false,

    The corresponding XML excerpt:

    <link href="EmployeeEmployeeTypeCollection('0000000000011EE181BFC430CB1AAE84')/Employee" rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/Employee" type="application/atom+xml;type=entry" title="Employee"/>
    <content type="application/xml">
    <m:properties>
    <d:ObjectID>0000000000011EE181BFC430CB1AAE84</d:ObjectID>
    <d:ParentObjectID>0000000000011EE181BFC41244F70E84</d:ParentObjectID>
    <d:EndDate>9999-12-31T00:00:00</d:EndDate>
    <d:StartDate>0001-01-01T00:00:00</d:StartDate>
    <d:InternalEmployeeIndicator>false</d:InternalEmployeeIndicator>
    </m:properties>
    </content>
  7. asmaMdi commented on Feb 12, 2020

    @asmaMdi
    Author

    Thank your for your response. I will see with the OData service provider.

  8. filak-sap commented on Feb 12, 2020

    @filak-sap
    Contributor

    @asmaMdi If they refuse to fix the problem on their side, we will find a way how to work around this issue.

  9. asmaMdi commented on Feb 13, 2020

    @asmaMdi
    Author

    Great! Thank you very much
    I reported the problem to the OData service provider.

    Thank you

  10. filak-sap commented on Feb 24, 2020

    @filak-sap
    Contributor

    @asmaMdi thank you for the follow up. I am going to close this issue and I would like to ask you to re-open, if the service provider does not fix the issue on their side. I would like to thank you for your cooperation and patience.

  11. squeakyboots commented on Apr 3, 2020

    @squeakyboots

    @asmaMdi did you hear back from the provider? I also seem to be facing this issue on ByD and am curious what the outcome was.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions