Problem with Date field after migration from mysql to oracle - mysql

I have lately migrate my JIRA database from mysql to oracle,
my problem is the field "created" exists in the jiraissue and changegroup tables,on this field I effectuate many calculation but I was surprised by the difference of the format of the fields.
in mysql database the field creation has the type timeStamp so it has the follwing format:
and in Oracle database it has the type date and the format like the following:
How can I resolve this problem?

The format of your displayed Oracle DATE column is due to your IDE that you are viewing it through.
Oracle stores all portions of a date, to display the full date stored use this:
SELECT TO_CHAR(created, 'DD-MON-YYYY HH24:MI:SS')
FROM jiraissue;
This will show you the full date that has been stored including the time portion. To store timestamps you need the column to be designated as a timestamp datatype column.
Ollie.
EDIT: You could change the NLS Date Format of your IDE to always show the full date format in it's settings somewhere.

Dates are not held as formatted text in Oracle. What you are seeing is a tool's (Toad's?) default formatting of the date to display it to you. This can be changed via a preference somewhere. It could be that the time component has been lost in migration, but that is unlikely. Try running this SQL to see:
select to_char (created, 'YYYY-MM-DD HH24:MI:SS') from jiraissue;
That should show the dates just as they appeared in MySQL.

Related

informatica Datetime conversion to SQL server Timstamp

I have a requirement where I have to load Informatica SESSSTARTTIME(datetime) to SQL server timestamp. When I am trying to connect datetime to timestamp I am getting error incompatible data type. 
Any suggestions how this can be achieved? 
Thanks
I had a similar issue in the past, where the date column was not getting loaded because of the difference in precision of date/time used by Informatica and SQL server. You can try this workaround: Change the data type in the target definition (not in SQL Server table, only in Informatica Target definition) to String, then Informatica will pass the date/time value in quotes when firing the insert query, which SQL server can convert to date/time automatically.
in the mapping try to create output port in expression as sessionstarttime (which is a inbuilt variable) and pass it to target
hope this will help to get desire output
in session there is config tab where you can change the format for date and time
MS SQL Server timestamp datatype has nothing to do with time. It's an autogenerated number and you cannot load it.
https://msdn.microsoft.com/en-us/library/ms182776(v=SQL.90).aspx
quote:
"Is a data type that exposes automatically generated, unique binary numbers within a database. timestamp is generally used as a mechanism for version-stamping table rows. The storage size is 8 bytes. The timestamp data type is just an incrementing number and does not preserve a date or a time. To record a date or time, use a datetime data type."

Displays the date in MySQL Workbench

How to change the display of dates in MySQL Workbench
Recorded as 16-01-2014 now
But is necessary to do so: 16-01-2014
You'll need to change your SELECT statements to get your dates rendered differently.
Change
SELECT datestamp
to
SELECT DATE_FORMAT(datestamp,'%d-%m-%Y')
MySQL Workbench is a client program that accesses MySQL database servers. You use the workbench to write queries to send to a MySQL server to get back data.
If you want your dates presented in a particular way, that's part of the queries you write. If you use the queries built in to the workbench, you can't change the date format it displays.
Don't give in to the temptation to change the data type of your date and time columns in your table to VARCHAR(), and then fill them with values in the format you prefer. If you do that, you'll lose the ability to search your table on date ranges.

php/mysql routine to help me extract all dates strings stored in a column as text dd/mm/yyyy into another fresh column with mysql date datatype

i am new here and i need help with writing a php/mysql routine to help me extract all dates strings stored in a column as text in this format dd/mm/yyyy into another fresh column with mysql date datatype in the format yyyy-mm-dd.
i have tried to query through the table using a date range and it seems not to work, so i have resolve to change th already store dates into the proper mysql format to enable me query with date easily.
indeed i am most greatful of any assistance i get.
thanks
Handyx
First of all you probably shouldn't be doing what your doing, convert the date on the go. Nevertheless here's the SQL query to do what you want to do
USE `DATABASE`;
UPDATE `TABLE_NAME` SET `TABLE_NAME.NEW_COLUMN` = DATE_FORMAT(
STR_TO_DATE(`TABLE_NAME.OLD_COLUMN`,'%d/%m/%Y'), '%Y-%m-%d');

phpmyadmin export of date int(11) to CSV dd/mm/yy format

Im new to SQl and trying to do a dump through phpmyadmin.
At the moment date data is stored in my DB as int(11).
When I export from phpmyadmin, the data is naturally exported as numbers like '1325336400' but i would like this to display as 01/01/2012 or similar format. is there any way I can do this?
Many thanks in advance
Jus
If you're storing your "date data" (as you put it) in 32-bit integers, I guess you are using *nix timestamp values (seconds since the 1-jan-1970 00:00 UTC epoch).
(You know this may overflow sometime in 2038, right? http://en.wikipedia.org/wiki/Year_2038_problem)
phpmyadmin has a hard time with these values, as you have discovered.
MySQL has a TIMESTAMP data type which also uses *nix-style timestamps. (It won't overflow; the MySQL developers did the right thing.)
You really do need to convert your date data to the TIMESTAMP data type. Otherwise dealing with time will be a huge pain in the neck, forever. Here's how to do it.
First, add a column to your table in this way,
ALTER TABLE mytable ADD COLUMN ts TIMESTAMP AFTER myinttimestamp
Then populate your new ts column using the values you already have.
UPDATE TABLE mytable SET ts = FROM_UNIXTIME(myinttimestamp)
Next, change the definition of your new column so it disallows NULL values and uses the current time as a default:
ALTER TABLE mytable
CHANGE ts
ts TIMESTAMP DEFAULT CURRENT_TIMESTAMP NOT NULL
Finally, if you want you can get rid of the old column with the INT values in it.
ALTER TABLE mytable DROP COLUMN myinttimestamp
(You should consider trying all this out on a copy of your table; it would stink to make a mistake and wreck your data).
When you use the TIMESTAMP data type, MySQL does its best to store all these timestamps internally in UTC (time-zone-insensitive) time, and convert them to local time upon display, based on how you set
SET time_zone = 'Asia/Vladivostok'
or whatever. It will also convert them from local time to UTC time when you put them in to the data base.
Here's a write up.
https://dev.mysql.com/doc/refman/5.5/en/time-zone-support.html

Dealing with different datetime formats in the DB?

I'm writing a Ruby program using Sequel which is running on the legacy database. There is an issue dealing with different date time formats.
DB has a table which has a column start_date. In Sequel's migration script I set it to DateTime which is a timestamp type in SQLite, however, the legacy data has a different time format:
Some are using an ISO8601, like 2013-09-01T08:28:00+10:00.
Some are using a different one, which I don't know if it has a name, like 2013-09-01 08:28:00.000000+1000.
The problem is, when I run a query against the table and try to filter by start_date, the difference between two date time formats will cause incorrect results.
The query I'm using is:
current = Time.now
MyModel.where { start_date < current }
Sequel will convert it into SQL like this:
SELECT * FROM `my_model` WHERE `start_date` < '2013-09-01 08:28:00.000000'
From my local testing, Sequel looks like it's comparing the date as a string, so 2013-09-01 08:28:00.000000+1000 is less than 2013-09-01T01:28:00+10:00. Because whitespace is less than T this is not what I want.
I could use an iso8601 time like:
current_iso8601 = Time.now.iso8601
MyModel.where { start_date < current_iso8601 }
But it won't solve the problem because the database has two different datetime formats.
My questions are:
Does Ruby/Sequel support querying the database by Date/Time not as a string?
Does it work for different date time formats?
SQLite is just for local testing, in production it will be MySQL. So, the solution should be using general Sequel methods as a adaptor and should not have any database specific methods.
NOTE: the program is not a Rails application.
Thank you very much!
SQLite does not have date/time types (see http://sqlite.org/datatype3.html). It stores datetime values as strings.
The best solution is to use the same database in development/testing that you use in production. If you don't want to do that, you need to convert all the SQLite datetime values so that they all use the same ISO8601 format. That way the comparison operators will work correctly (as they do in MySQL).