0

I wrote the codes short due to the maximum code text length.

I'm trying use Datatables. Datatables configure like this..

  var table = $('#myTable').DataTable({
        "destroy": true,
        "scrollY": "500",

        "scrollX": true,
        "processing": true,
        "ajax": {
            "url": "/GetData/GetWeeklyData"
        },
        "columns": [
            {"data": "RecordDate"}
        ]
    });

But recordDate value format is /Date(-62135596800000)/

image

GetWeeklyDate is;

  public List<DefaultLogs> GetWeeklyData()
    {
        try
        {
            var client = new MongoClient(_appSettings.MongoClient);
            var filter = Builders<DefaultLogs>.Filter;
            var database = client.GetDatabase(_appSettings.MongoDbName);
            var collection = database.GetCollection<DefaultLogs>(_appSettings.CollFilteredLogs);

            var endDate = DateTime.Now;
            var startDate = endDate.AddDays(-7);

            var query = filter.Gte(x => x.RecordDate, new BsonDateTime(startDate)) & filter.Lte(x => x.RecordDate, new BsonDateTime(endDate));

            var result = collection.Find(query).ToList();
            return result;
        }
        catch (Exception exception)
        {
            Console.WriteLine(exception.Message);
            return null;
        }
    }

Data model;

  public class DefaultLogs
{
  
    public DateTime LogDate { get; set; }
    
}

Datetime value is correct in C# side.I think I need to send it as String.How can I?

0 Answers0