Serializing dates to JSON seems to alter the date one hour back - sql-server

I'm trying to understand why dates stored in my MSSQL server are being altered back one hour when I view them in JSON format.
Here is the Datetime date stored in MSSQL
2015-08-12 00:00:00.000
Here is debug mode in Visual Studio showing that the date "appears" to be retrieved correctly from the database.
{8/12/2015 12:00:00 AM}
And here is the JSON output - the date is one hour earlier! I see that the json timezone is -6, and the database timezone doesn't appear to have that, but I don't have any special settings in my web api config. I'm really not understanding what is going on here. Appreciate any help.
"2015-08-11T23:00:00-06:00",
Edit: My pictures didn't show up so I edited to show the dates in text format - hope that is allright.

When moving to OData V4 (from earlier versions) one of the first 'hickups' we run into is that V4 does not support 'DateTime' but 'DateTimeOffset'. In .Net terms we're moving from a "Date assumed to be in locale timezone of the server running it" to "DateTimeOffset" which explicitly included the timezone information itself.
OWin will emit the DateTimeOffset based on your thread's culture info. Your solution will then lie in making sure when converting between "DateTime" and "DateTimeOffset" (DB/EF and OWin respectively) that you don't rely on your local thread's locale setting, but force it to be considered UTC.

Related

Two date parameters while connecting Google Data Studio with BigQuery

As I read in this link "Report viewers can't modify data source parameters directly. However, if you've enabled date parameters for a BigQuery data source, and your report includes a date range control, viewers can use that control to request different starting and ending dates from the BigQuery data."
I'm facing a situation where I need to filter two periods at the same time and over the same data source:
Period where users installed my app.
Period where users made actions.
For now, Data Studio permits only one date parameter in customized queries for BigQuery (DS_START_DATE, DS_END_DATE). But what if I need an additional date parameter? Is there a solution to this need?
Include all the data from BigQuery to Data Studio first, then set custom date range for the specific charts/tables.

How to avoid the "Z" in my PostgreSQL datetime

I am using the material-UI to select a date and store it in a SQL Database. When I send the date to the DB it is in this format "YYYY-MM-DDTHH:MM" for example "2017-05-24T10:30". However when I fetch the dates from the DB they come out like this "YYYY-MM-DDTHH:MM:SS.000Z" for example "2019-06-14T10:30:00.000Z"
Now I am using a calendar package called FullCalendar, which interprets the "Z" as -5H. So all of the dates on my calendar are moved back 5H. The really bazaar thing is that this only happens when the app is deployed on Heroku. If I run the app locally and try to fetch the dates the database is automatically adding 5H to the times to compensate for the "Z" and the dates are displayed correctly on the calendar.
I'm looking for a solution to either get rid of the "Z" or make the heroku and local app deployments consistent.
I'm not sure if there is any relevant code to include here. The POST and GET methods to the DB are pretty standard. Let me know if I can add anything that might be of use.
Without more information, this will be the easy solution (not the best):
SELECT LEFT(cast('2019-06-14T10:30:00.000Z' AS varchar),16)
Result: "2019-06-14T10:30"
Look at these functions for better answers in terms of performance: AT TIME ZONE, date_trunc
https://www.postgresql.org/docs/9.1/functions-datetime.html

wso2 dss 3.5.0 subtracting hours from datetime

data source = dateTime 2016-02-26 00:00:00.0
dss return = dateTime 2016-02-25T09:00:00.000-03:00
I would like to know if there is any settings to be made in the tool itself.
Let me briefly explain what you have received from the WSO2 Data Services Server (DSS).
It's not subtracting some hours from the date stored in your database. Actually, DSS server appends time zone information to your date fields.
Do you really want your date fields without time zone information? At the moment, I would like to suggest (as a workaround ) manually remove time zone information once you receive the response from the DSS server.
In the meantime, I have raised a public JIRA [1] regarding this issue and will notify the progress of it via this question.
Thanks,
Upul
[1]. https://wso2.org/jira/browse/DS-1191

how to change timezone setting in Lucid Work Enterprises

I have installed Lucid Work Enterprises and notice that its displaying time of UTC zone. But my system timezone is UTC+05:30. so there is always a difference in my database last_modified field value for delta query for indexing (as there is 5:30 Hrs difference in Lucid admin timezone and my database timezone).
I tried to change a setting in start.bat file from
"set MISC_OPTS2=-Duser.language=en -Duser.country=US -Duser.timezone=UTC -Dfile.encoding=UTF-8"
to
"set MISC_OPTS2=-Duser.language=en -Duser.country=US -Duser.timezone=UTC+05:30 -Dfile.encoding=UTF-8"
But it doesn't make any difference.
I am unable to find a way to change timezone setting in Lucid admin area. Even there was no option to select timezone in installation wizard.
Please help me that how i can change this timezone setting for Lucid.
Thanks in advance
I had a similar issue using lucen/solr (without LWE). At solr ther is (also) no way to configure the timezone. Asking an Partner from "Lucid imagination" how to handle time-zones with lucene/solr, i get the answer: change timezone-settings at your J2EE servlet container options.
But as you said:
But it doesn't make any difference.
My workaround is realized by the application, which handles the "time-zone-difference" between lucene- and database timestamp. Not sure, which programming language you are using. PHP for example provides nice build-in functionality for handling dateTime objects and different timezones.

Date formats mismatch between different servers (XML column)

I am facing a problem for past two days with regard to the date format in SQL.
I have developed a application in ASP.NET and have deployed it in production server. I am persisting data into a table which has an xml column with date feilds like
---some date time---
When I run the application from localhost ( or deploy the application in my computer) the date is persisted in in 24 hours time format
For eg :15/08/2009 14:30:00
and when I run the same application deployed in the production server the data is persisted in 12 hours time format
For eg: 15/08/2009 2:30:00 PM
Note: I am not specifying any format in the application code when persisting data.
The following is what I have tried :
Checked regional settings of my computer and the webserver and format is the same (h:mm:ss tt)
Have checked the culture info of both my computer and webserver and it is the same. (en-AU)
In my computer's IIS Properties I have set the same culture of the webserver by Editing the configuration.
The dates in date columns of the same table are stored in consisntent format (24 hr format) when persisted from both my computer and the production webserver.
For eg: 2009-10-28 14:00:49.000
Still the date time is stored in different formats. I am unable to figure out from where the application is taking the format when persisting.
I finally found the root cause for this problem. I would like to post it just in case someone faces this same problem this might help them.
Go to regedit. Select Controlpanel -> international -> sTimeFormat and verify the time format given.
In my computer, the time format is HH:mm:ss and in server it is hh:mm:ss tt that was the main problem. I have changed the format in server to HH:mm:ss and it works perfect :)
Please refer to this link for details.
Try add the following to the web.config of your website:
<system.web>
<globalization culture="en-ZA" uiCulture="en-ZA"/>
</system.web>
Replace "en-ZA" with the specific culture you require. The will ensure that the browsers culture settings will not be used.

Resources