If you want to go directly to the solution: Click [here](Go-to-solution)
One of my biggest mistakes in the past was the Datetime value in SQL. Seriously.
In all my code when i want to create a registry in the database, one of my practices is using the created_at, because who knows! Maybe in the future will be neccessary.
But, in my curiosity checked in which hour are more often the registrations and it was very strange to see hours like “1 AM” or “3:30 PM” because well, or everybody are sleeping or working.
So, let’s go to basic!
It is time to do the research 🔍.
I use Azure SQL databases because it’s more familiar for me -and i’m to lazy to use another one- but it is really cool to use Entity Framework with Microsoft SQL out-of-the-box, maybe this is the main reason.
Yeah i know, there are many ways to check the server hour in sql, but i like this one, it’s very simple.
The result? It’s different, then, maybe this is the culprit, but one of my teachers in the past told me:
“If it’s too easy is because or it was or you are doing it wrong.”
I need one more suspect before finish my research.
My favorite ORM, maybe it’s not the best but it is always there, like a buddy.
In local, i run SQL Server Profiler to check the final query for insert into the database… and notice something strange.
The final code includes the datetime already in the insert query. Aha! I know it was not that easy. I need to go even further back.
How can i check the date in the server if i was using an App Service? It was my first thought.
Checking out the options in the azure app’s panel, i look that there is a console option(under Development Tools), when i clicked on it, it was an Powershell!
I’m not expert, but there is 2 useful commands to check it out what is going on, date and time, and the second one was the answer of all of this.
Finally, it’s time to fix this.
Under settings, click on Application Settings.
There are 4 different configuration things, you need to go to Application Configuration section and add a new setting “WEBSITE_TIME_ZONE”.
In value, you need to find your timezone and add the value, for me, it was Central Standard Time.
Click on save, wait for the finish and you are done!
Today we learn:
Are you in trouble? Have any questions? Contact me
A person from the systems area has been imprisoned after being fired for having bad performance, but how can he/she…
The hackers sneaked in a back door using the Asus update software, targeting specific computers but affecting thousands of users…
Facebook confirmed thursday in they blog that they stored "hundreds of millions" password in plaintext FOR YEARS
It's time to another how-to series! This time we will learn about the object as values and how-to read it…