Why are my dates off by one day? - json

I have a SQL Server table the contents of which I'm displaying in an MVC page using Kendo UI Grid. One of the columns in the table is named RecordDate and is a SQL Server Date type (not a datetime variant).
When my page requests data, I'll retrieve some rows, convert to Json (as shown below) and return them to the client.
return Json(resultSet, JsonRequestBehavior.AllowGet);
The problem is all the dates are off by one day when displayed in the Kendo grid. I suspect something along the way is assuming the dates are stored as UTC dates (which they are not) and then attempting to convert to local time. However, I have no idea where this is happening, why and how to stop it.

We have recently had a similar issue, there are a number of links which discuss this:
Stringify modifying dates
How to prevent modification of times
Server changing dates sent by client
Notably the best/most acceptable resolution (and one we decided to use) seems to be the use of the moment.js package to handle dates. However, as you will see throughout the links above, this is open to interpretation.

Related

Uploaded CSV file shows Date column as strings, how to convert to Dates for AutoAI use?

I was trying out the AutoAI feature on the IBM cloud with a CSV that only has two columns: a date column and a change column (1 or 0). When I upload it, as a data asset, it sees the Date column as a string. Even after going through data refinery and converting it to a date, when AutoAI reads the file, it still sees it as a column of strings.
How do I make AutoAI recognize the date column as a column?
Blockquote
Unfortunately , date recognition doesn't work on AutoAI at this moment. However, next year there is going to be an update of the autoai service where you will be able to have that feature. If you want to test it, there is a demo version of that: https://autoai.mybluemix.net/home
Blockquote
Just to add a comment to Aleksandar's comment regarding the AutoAI Demo: it is a research demo thus it is not exposed to the general public. It needs further authorization (either an IBM w3id or a special login/pwd through an IBM sales representative).
And to answer the question, we are fully aware the user needs for the TS dataset and the Date/Time detection function, and it will be out very soon.
Unfortunately , date recognition doesn't work on AutoAI at this moment. However, next year there is going to be an update of the autoai service where you will be able to have that feature. If you want to test it, there is a demo version of that: https://autoai.mybluemix.net/home
The time series support is not in place yet. There is on-going effort to have first version available this year.
There is workaround option but not perfect (AutoAI will NOT treat data as timeseries):
do the preprocessing / features creation on your own (create features like year, month, day, week etc.)
pass such preprocessed data to AutoAI
Drawbacks: it will not be treated as ts data. Model validation (cross-validation), folds building will not take into account time order what may lead to unreliable metrics values.

How to handle product delivery times in mysql?

I have a winform application and a mysql server saving the data.
I created a form from which users can save/update/delete records pretty normal stuff.
The problem comes when I added the delivery time functionality where the product has a expected, standard time in which it will be delivered; so say it has a six day expected time the form would calculate the expected time and show it back to the user, straight forward.
I've tried using a DATETIME column but after reading mysql documentation it has upper and lower limits so I cantĀ“save say '0000-00-01 12:30:00'. So how do I save that kind of data into mysql? Whats standard practice in this topic?

how to get the date from left to right in mysql?

what to do, that I get the Date like that 08-06-2017 and not 2017-06-08 ? in the table of mysql
Because I send the date_value to server like that 08-06-2017
Don't do it, it's going to be a mess. First of all the mysql date, date time and timestamp types do not support being stored in different formats. You could however select them with a different formatting, if you wanted to (https://dev.mysql.com/doc/refman/5.7/en/date-and-time-functions.html#function_date-format). If you absolutely have to store dates in a specific format, you would have to use text or varchar as type. But then your next problem is going to be ordering and grouping over date fields like that.
My recommendation would be to just stick with the mysql date format and do transformations between the different formats in whatever MVC framework you're using inside the controller or view. That's what they're for. This also leaves you open for the possibility to use different date time formatting based on user locale.

Access Web Application Data Macro to Sum values in Query and return as variable

I am working on a small application in Access Services on SharePoint to log colleagues leave requests, and I need to work out a data macro to calculate how many days of leave they have remaining from their allowance.
I have a table [Colleagues] with all of the user data, for simplicity I'll reduce it to [Email] and [Allowance] in days. I have another table which stores the requests [Requests] including the number of days to deduct in each approved leave request [Days Requested].
I have set up a query that returns all approved requests for the colleague and I would like to use a data macro that is triggered to run when the colleague logs in. As you cannot use aggregate functions in Web Applications, I am currently using ForEachRecord in the query to total the number of deductible days, however I cannot work out how to return that to a field in the [Colleague] record.
According to the Access help, I should be able to set the value to a LocalVar and use it in expressions as simply as referencing [Deductible Days], however this is not working.
Any help?
I finally worked this out after much tinkering.
In my query I included the [Colleague Email] field as well as the [Days Requested] field, and then when my Application loads it navigates to a form created from the [Colleagues] table. I have modified the Data Source of the form to link the [Email] field in the query results to the [Email] field in the [Colleagues] form.
Following this I was able to create an unbound textbox with the data source =Sum([Days Requested]) referring to the relevant field in the query. Voila! I now have the value to play around with in my application.
Hope that helps, took a lot of fiddling around. No data macros needed after all, but its a method I shall remember in future, opens up a lot of possibilities.
If I understand your situation correctly, I was faced with a very similar problem.
I believe the solution used here will work for you. It involves using a query to Sum up the values (we would use Sum where he used Count), use a Data Macro to run the query and then have have an On Insert/On Update trigger the Data Macro:
http://devspoint.wordpress.com/2014/03/26/validating-data-with-data-macros-in-access-services-2013/
Let me know if this works for you. It worked for me!

Google Refine and fetching data from freebase for a large data set to create a column from URL not working

I have a google refine project with 36k rows of data. I would like to add another column with fetching json data from freebase url. I was able to get it working on a small dataset but when i ran it on this project it took few hours to process and then most of the results were blank. I did get some results with data though. Is there a way to limit on amount of rows the data will be fetched or a better way of getting the data from the url.
Thank You!
If you're adding data from Freebase, you'd probably be better off using the "Add column from Freebase" rather than "Add column by fetching URL."
Facets are one of the most powerful Google Refine features and they can be used to control all kinds of things. In this case, you could use a facet to select a subset of your data and only do the fetch on that subset (and then repeat with a different subset).
The next version of Refine will include better error reporting on the results of URL fetches to help debug problems like this, but make sure that you're respecting all the limits of the remote site as far as total number of requests, requests per second, etc.