#

SQL Datentypen

 

Umwandlung von Date Time Datentypen in C# , JSON und Excel

 

 

SQL Server

Datetimeoffset(7) 

2021-01-21 14:00:00.0000000 +01:00

Datetime2(7)

2021-01-21 14:00:00.0000000

Time(7)

14:00:00

Date

2021-01-21

 

Asp.Net C# Model

public DateTime? DtDate { get; set; }

public DateTime? DtEdit { get; set; }

public DateTimeOffset? DtStartOffset { get; set; }

public DateTime? DtEnd2DateTime2 { get; set; }

public TimeSpan? DtStartTime { get; set; }   

 

In JSON

    "dtDate": "2021-01-21T11:24:27.793Z",

    "dtEdit": "2021-01-21T11:24:27.793Z",

    "dtStartOffset": "2021-01-21T11:24:27.793Z",

    "dtEnd2DateTime2": "2021-01-21T11:24:27.793Z",

    "dtStartTime": {

      "ticks": 0,

      "days": 0,

      "hours": 0,

      "milliseconds": 0,

      "minutes": 0,

      "seconds": 0,

      "totalDays": 0,

      "totalHours": 0,

      "totalMilliseconds": 0,

      "totalMinutes": 0,

      "totalSeconds": 0

    }

 

 

 

 

 

 

      [dtStartOffset] [datetimeoffset](7) NULL,

      [dtEnd2DateTime2] [datetime2](7) NULL,

      [dtStartTime] [time](7) NULL,

 

 

In C# Asp.Net Model

    public partial class TimeRecord

    {

        public int IdtimeRecord { get; set; }

        public DateTime? DtDate { get; set; }

        public string Project { get; set; }

        public string Details { get; set; }

        public string IduserGuid { get; set; }

        public DateTime? DtEdit { get; set; }

        public DateTimeOffset? DtStartOffset { get; set; }

        public DateTime? DtEnd2DateTime2 { get; set; }

        public TimeSpan? DtStartTime { get; set; }

    }

 

In JSON

  {

    "idtimeRecord": 1,

    "dtDate": "2021-01-21T00:00:00",

    "project": "API TimeRecords",

    "details": "Tabellen in SQL",

    "iduserGuid": null,

    "dtEdit": null,

    "dtStartOffset": "2021-01-21T14:00:00+01:00",

    "dtEnd2DateTime2": "2021-01-21T14:00:00",

    "dtStartTime": {

      "ticks": 504000000000,

      "days": 0,

      "hours": 14,

      "milliseconds": 0,

      "minutes": 0,

      "seconds": 0,

      "totalDays": 0.5833333333333334,

      "totalHours": 14,

      "totalMilliseconds": 50400000,

      "totalMinutes": 840,

      "totalSeconds": 50400

    }

  },

]

 

 

 

In Excel

 

Im Excel Power Query Editor

 

Name

Wert

idtimeRecord

1

dtDate

2021-01-21T00:00:00

project

API TimeRecords

details

Tabellen in SQL

dtStartOffset

2021-01-21T14:00:00+01:00

dtEnd2DateTime2

2021-01-21T14:00:00

dtStartTime

[Datensatz]

 

Mobile

.