Converting Oracle timestamp(6) to datetime - sql-server-2008

I am pulling data in from an Oracle source (SSIS). After a week of successful run, a timestamp of '6/19/0002 12:00:00 AM' shows up. How do I convert this to SQL server datetime? I am fine with just setting this as null, but how do I detect invalid dates in ssis?
SQL Server 2008/SSIS 2012
I do not have control of Oralce source.
Thanks

I think you are probably looking for datetime2(6) in SQL Server 2008.
Defines a date that is combined with a time of day that is based on
24-hour clock. datetime2 can be considered as an extension of the
existing datetime type that has a larger date range, a larger default
fractional precision, and optional user-specified precision.

Related

Migration of Data from Oracle database to SQL Server

[ADO NET Destination [2]] Error: An exception has occurred during data insertion, the message returned from the provider is: SqlDateTime overflow. Must be between 1/1/1753 12:00:00 AM and 12/31/9999 11:59:59 PM.
I don't understand the error message from SSIS. Please I need help.
Thanks
In C#, when the data is converted from NULL to DateTime, the DataTime.MinValue = 0001-01-01, but in database, the min value is 1/1/1753, so you have to make some treatments to NULL, otherwise when inserting 0001-01-01 (converted from NULL), it will throw you that error.
It is probably problem with different date formats on both sides, maybe different language setting for both databases. For example Oracle uses dd-MM-yyyy and SQL expects MM-dd-yyyy. Try to select datetime fields from both databases to check the format. Then try to solve it by some type of conversion in SSIS. You can try converting Oracle date to universal datetime format and then converting back to MS SQL date format. Of course, SSIS should solve it automatically, but working with dates is often buggy and confusing.
The other possibility is, that you are trying to convert TEXT column in Oracle to datetime column in MSSQL and one of the values in the table does not fit expected date format.

Timezone conversion in ssrs expression

I take the UTC date from the sqlserver.
I have to display the local date and time in the report.
How to convert the utc datetime format into local datetime in the expression?
I tried this
=System.TimeZone.CurrentTimeZone.ToLocalTime(Fields!DateTime.Value)
but doesn't work for me

MySQL: Data truncation: Incorrect datetime value: '2006-10-01 02:22:44'

I'm getting the following exception updating a row using MySQL via JDBC:
com.mysql.jdbc.MysqlDataTruncation: Data truncation: Incorrect datetime value: '2006-10-01 02:22:44'
The column is defined as:
'created_on_service timestamp NULL DEFAULT NULL'
There are no indexes or foreign keys on that column.
Obviously it's not a problem with data type. I have values in that table from both before and after that datetime. I also have values with times both before and after 2:22 AM.
Solved it.
Turns out that the 1st of October 2006 in South Australia was the start of daylight savings. Clocks get set forward one hour at 2.00am, so there was no 2:22am on that date: it went straight from 2:00am to 3:01am.
I'll change the db timezone to UTC, which should solve this issue.
I fixed the same problem (com.mysql.jdbc.MysqlDataTruncation: Data truncation: Incorrect datetime value: '' for column 'perev_start_time' at row 1) by upgrading my MySQL connector JAR, and copying the mysql.jar to the Tomcat lib directory.
The version of MySQL Server is 5.6 and the MySQL connector is mysql-connector-java-5.1.30-bin.jar.
We upgraded MySQL server but didnt upgrade the mysql connector jar. We encountered this issue. Later I figured out it was due to the old jar. I upgraded it and this issue went away.
My problem was caused by DST, too. I've fixed it by changing column data type from timestamp to datetime. This answer describes the difference, in short:
timestamp stores time as Unix epoch time, so converts it to/from UTC according to server's time zone. Once you change server time zone, you have different interpretation for INSERT/UPDATE and different SELECT results. Some time points are invalid due to DST;
datetime stores time as is, regardless of server time zone. When passing UTC time, any time is valid (there are no DST "holes").
Note: you may still have to deal with "missing" time. This approach just shifts responsibility from DB level to application level.
See also: MySQL documentation for TIMESTAMP vs DATETIME
You did not show exact update SQL. But may be you forget the date part
The correct format is yyyy-mm-dd hh:mm:ss format
Date value should be in following format 2011-11-01 12:32:01

SSRS Azure DateTime to LocaldateTime Conversion

I've written a report that extracts the data from SQL Azure storage. Looks like DateTime are stored on server datetime (based on South east asia).
When I render the report the date time is very confusing to the users as it's not a local datetime. Could anyone please suggest how to convert the serverdatetime to local datetime in SSRS, please?
Thanks
I think that is not the local datetime but UTC. You can handle all the timestamp and server time by explicitly by converting it to localtime stamp from UTC.

Date Conversion problem

I was about to import data from a table in MySQL to SQL SErver 2008 through SSIS. But I cant transfer due to Dates in the table. There are some data of datetime data type, like '0001-01-10' which doesnt support in SQL Server where years in date ranges from 1753 to 9999. So how do i solve this in MySQL queries ?
If those dates are valid data, then there's no easy way to deal with that in SqlServer. Basically, a custom date handler is needed. A good-enough approximation might be achieved by separating the year into a single integer field and putting the month and day into a date field with a constant year. Every comparison would then be compound.
More likely—for most business applications—such dates are useless and should be cleaned up, or replaced by NULL values.
Note that none of the SSIS data types are truly equivalent to the SQL Server datetime or smalldatetime types, with their restricted range of allowable dates.
A lot of online documentation suggests the DT_DBTIMESTAMP is equivalent to SQL datetime. This is only true up to a point. Dates outside the allowed datetime range will happily cast to DT_DBTIMESTAMP (or any SSIS date type) - but will then cause an error if you try to write them out to an SQL datetime column.
Confusingly, SSIS represents external SQL datetime columns as DT_DBTIMESTAMP, suggesting that datetime and DT_DBTIMESTAMP are equivalent, when they're not.
This means that you can't anticipate out-of-range date problems in SSIS by casting. If you're eventually going to write to datetime or smalldatetime columns, you have to do an explicit check that the date is not out of range (<1/1/1753, or 1/1/1900 for smalldatetime).