'C# DateTime with MongoDb

I'm trying to parse DateTime as Json to MongoDB.

This is my Post Request via Json :

    {
      "birthdate": "2022-05-19T19:27:44.952Z"
    }

This is the part of my C# class:

public  DateTime Birthdate { get; set; }

However in the MongoDB it is stored like this:

0001-01-01T00:00:00.000+00:00

But this works:

public  DateTime Birthdate { get; set; } = DateTime.Now 

however I want to store a custom DateTime



Solution 1:[1]

There’s not really enough information here to give a complete answer, but in the console you would need to wrap the string in an ISODate.

{
  "birthdate": new ISODate("2022-05-19T19:27:44.952Z")
}

See:

https://www.mongodb.com/docs/manual/reference/method/Date/

Solution 2:[2]

validation_data needs to be a tuple, as stated in the Keras API reference (link):

validation_data: ... validation_data could be: - tuple (x_val, y_val) of Numpy arrays or tensors - tuple (x_val, y_val, val_sample_weights) of Numpy arrays - dataset ...

A tuple (x_val, y_val) of Numpy arrays or tensors.
A tuple (x_val, y_val, val_sample_weights) of NumPy arrays.

Reference to a similar question: https://stackoverflow.com/a/63604307/10145479

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Victor Wilson
Solution 2 Rich