Base solution for your next web application

Activities of "bilalhaidar"

Hi, I finally made it work. In one of the entities, I need to provide a value for Id. However, Id is configured to be Identity Column.

Therefore, I had to make use of the following:

_context.Database.ExecuteSqlCommand("SET IDENTITY_INSERT dbo.DrcYesNoDecline ON");
                ...
                _context.SaveChanges();
                _context.Database.ExecuteSqlCommand("SET IDENTITY_INSERT dbo.DrcYesNoDecline OFF");
Question

Hi, I have a calendar control to receive the Date of Birth of the person. The application zone is set to Beirut which is +2 GMT. On the server, I am using Utc Provider.

So, let's say the user selects his birthday as 4/11/2000, since I am using PrimeNG date picker, I see the date stored in the DB as 3/11/2000 21:00:00. (In summer, we are +3 GMT)

Next time, I want to edit the record, also, the Date of Birth shows as 4/11/2000.

Now, when I want to export the data to Excel, because I had the need to use PIVOTs in TSQL, so I am using a DataTable to read the data from the SQL (calling a Stored Procedure).

When I export the data, I see the Date of Birth field as 3/11/2000

Here is the code I am using to parse and format date in Excel:

case "System.DateTime":
    var dateTime = (DateTime?)pocDataTable.Rows[r][columnName];
    DateTime? tempDateTime = null;
    if (dateTime.HasValue)
    {
        tempDateTime = Clock.Normalize(dateTime.Value);
     }
     value = _timeZoneConverter.Convert(tempDateTime);
     break;

Thanks :)

Answer

Okay, I have an update!

The date 3/11/2000 21:00:00 is indeed a UTC date representation of 4/11/2000 00:00:00+3 that I receive from the client.

When the client renders the value it is being rendered correct as 4/11/2000.

Now, when exporting to Excel:

tempDateTime = Clock.Normalize(dateTime.Value);

tempDateTime is just the date stored in the Database in UTC format.

This line below, is keeping the date in UTC format, hence the reason I am getting this weird behavior:

value = _timeZoneConverter.Convert(tempDateTime);

Why the _timeZoneConverter is not picking up the Timezone set in the application and convertnig the date to it accordingly?

Thanks

Answer

Yes, I set it to my timezone which is Beirut. How can I check the value of the timezone being set while running the app?

Showing 631 to 635 of 635 entries