how to get the date from left to right in mysql? - 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.

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.

Two Different date formats for record in datetimefield - we want to have one format

In our app, we use Django 1.11 and mySQL.
In our production, we encounter a problem with the date format for a couple of columns.
For some record the returned format of DateTime field is in the form: 2018-03-03T14:48:43Z and for others 2019-06-19T14:28:46+01:00.
We would like to return only one format and I think that we prefer this: 2019-06-19T14:28:46+01:00.
How to easily update the older record to use the new format?

CURDATE functionality from db2 query

I'm trying to apply 'curdate()' functionality to a select statement from DB2. I'm used to MySQL but I'm still trying to get the hang of a lot of the DB2 functionality and how to essentially marry the two.
My query is complete except for one line. I'm trying to select based on a ship date, which is the column EXTD1H and I need to check it against today or curdate(). The problem is that column in DB2 is an integer format, not a date format, and I don't have the option of changing it. In prior inserts to mysql, I've been able to put it into Y-m-d format and I know I can trim the year using LEFT(EXTD1H, 4) but I have no idea how to modify my select so that I can say WHERE EXTD1H is today so that I'm only selecting records for this date.
Here's the query:
select
invnoz as ORDER,
fstatz as STATUS
from gportafl
/*where EXTD1H is curdate, hypothetically*/
AND FSTATZ <> 'S'
limit 20;
As you can see, I have a commented line where my issue is. I'm sure it's simple I just can't seem to find in the documentation exactly what I'm looking for, which is to be able to use that INT column to verify that selected records are from today.
UPDATE:
All values from the column are in YYYYMMDD format i.e.
20180202
but it should be 2018-02-02
It's best not to do operations on the columns, so the indexes are used.
You can typecast the current date to fit your data as follows:
WHERE extd1h = INTEGER(VARCHAR_FORMAT(CURRENT DATE,'YYYYMMDD'))

Why are my dates off by one day?

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.

SSRS - Is there a way to restrict date/time input parameters to date only? (Not report output field format.)

I am writing an SSRS report that has several parameters including a couple of date fields. I do not want the user to be able to enter time information in either date field, but SSRS only has the Date/Time data type. Is there a way to force these report parameters to act as date only, and can I set a specific format (e.g., dd/mm/yyyy)? I would like to keep the built-in date-picker-calendar functionality.
I do not want to write my own report parameter web page because if I did then this one report would be the odd one out given that all of our other reports (which don't use date parameters) work fine with the built-in SSRS parameter entry functionality.
Perhaps the answer is that you can't do it with the built-in options, but that seems crazy - how could something so obvious have been overlooked?
The Google and Stackoverflow searches I've done only gave me ways to set the format in the report output (actually there are a number of cases where people have asked a question similar to mine and only received answers about setting the output format).
The problem is that you are using parameters that get timestamp information.
For example, if you are using Now() in your expressions- you will be asking for the current date AND the current time. However, if you use Today()- you will only be asking for the current date.
=Today() 'returns date only
=Now() 'returns date and current timestamp
Useful references:
http://msdn.microsoft.com/en-us/library/ms157328(v=sql.90).aspx
http://msdn.microsoft.com/en-us/library/ms157328.aspx
To answer my own question based on research I've done since asking it: it seems it is not possible to control how SSRS handles user entry of date/time values in parameters. If there is a need to restrict to date (or time) only or do cross-field validation then you need to implement your own front-end - which unfortunately for my specific business case doesn't help.
In my experience it has only given me the date and time when the filed you are selecting from contains both date and time. I have found if I am selecting on a date only field then I only get the date in the parameter
There is a way, but it will require you to CAST your date as Varchar(10) in your parameter dataset.
Next,You'll have to choose "Data Type:" as Text under Parameters section.
Again, you'll have to make sure your SQL code re-converts it into date again. I do not prefer this way, but users really wanted to see date without time.
Let me know if you'd like screenshot or more detail.