Time field (in the format '02:00:00 PM' ) not able to export from Excel to MySql - mysql

I am trying to export data from excel(which I downloaded form a different source) to MySql using 'MySql for Excel' plugin, but I am facing issue with the time field. The format of the time is out of my control. I've tried with both formats(General and Time) in Excel. Still seeing this issue. Is there workaround for this?

Export it as a string, not a TIME.
in LOAD DATA, import it as a VARCHAR() into an #variable
use str_to_date() to parse it into the TIME column.

Related

How do I import column with values like '661-' into MySql?

I have a csv file from a legacy dbase dbf file. The data contains a few columns which have number values with hyphens. Like this '661-'. I am trying to import the csv into MySql using 'Import External Data' in MySql Yog. The issue is, the columns that have values with hyphens are getting imported as decimals resulting in '-661.0000'.
This is odd as the column format in the csv (via MS Excel) is 'general' not 'number' and I am trying to import these values into varchar fields. Seems MySql is ignoring the settings.
Has anyone faced something like this or have any suggestions on how I can get the data in as a string not a decimal?
Thanks
ANSWER - sorry to be answering my own question but I did solve it with some group input.
The file needs to be saved with all fields (that you want to be treated as string) in quotes. MS Excel DOES NOT seem to have an option for this. Apache Open Office does. Open the file in AOO and save as text.csv. From there you can edit the filters and set all cells to be in quotes. Problem solved.

CodeIgniter PHPExcel export to excel for 16 digit varchar data type error

I am trying to export a table from MySQL to excel in Codeigniter using PHPExcel. But for a column with varchar datatype [16 digits], the result in excel become something like a,bE+15. For example for 3374142005140004 in MySQL, in excel from the export it became 3,37414E+15 or 3374142005140000, so I lost the last digit value which is 4. The best file type to export to is OpenDocumentSpreadsheet (.ODS) [Tried it manually from xampp export file]. But PHPExcel doesn't have OOCalc writer yet. And I don't know how to integrate PHPMYADMIN export in CodeIgniter app. So, If anyone have the solution for this problem, please please share the solution. Thanks in advance for any help/suggestion.
If your string value is longer than a PHP integer, then you'll need to save it as a string using setCellValueExplicit() instead of setCellValue()
PHPExcel does allow you to write OpenOfficeXML files using the OpenDocument Writer

Convert a Unicode time in a CSV spreadsheet so I can import to MySQL date/time stamp

I'm stuck on this. I have a guestbook I'm converting from an old website into Wordpress comments. The guestbook has all the dates written in as unix. I already have the file transposed so I can import it into Wordpress comments and all works good, except the date field, which defaults to 0000-00-00 00:00:00.
I also have fields in standard Excel time formats but I need to find a way to conver that to the standard 0000-00-00 00:00:00.
Any ideas?
I actually figured this out after posting. Here was the issue. I had a CSV file from a previous guestbook that contained comments. In that CSV file the date / timestamp was in UNIX code (i.e. seconds since 1/1/1970).
In Excel, I found a formula to convert that to a date Excel can read. However, that date, when opened as a CSV, doesn't show in the correct format for MySQL. It uses the Excel date format, which is some string of numbers, I"m assuming similar to Unix time - from a certain date.
What I did was use the excel formula TEXT(Value, YYYY-MM-DD HH:MM:SS) to convert the excel date/time to a string in the correct format. Then the CSV file worked.

Date casting issue in data conversion task

my date format is in this format YYYYMMDD and when I am converting the same with data conversion task I am getting below error:
The data value cannot be converted for reasons other than sign mismatch or Data Overflow.
In my Dataconversion I have select DT_DATE
and in database the column datatype is date.
But the strange thing is that when I am executing my package and doing casting as source SELECT CAST(myDate AS DATE) package is working fine.
It's a common issue. If you use a derived column transformation, you will need to slice it out into the component parts (years, months, days) and then concatenate it back together before casting. That's ugly and time consuming for me.
Instead, assuming this is coming from a flat file, just make it a date on import by setting the type in your connection manager to the date type that will be compatible with your destination. Then on your flat file source, under advanced settings, set FastParse to true for that column. See my answer on Import String Date in Derived column for a pictoral walkthrough of it. Also addressed it on SSIS importing datetime column into SQL Server 2008

SQL Server Import Export wizard - error for datetime - specific values

I am using SQL Server 2008 Import Export wizard to bulk import a text file.
The text file contains more than 9 Lakh records with column delimiter | and row delimiter / terminator as {LF}
Everything is working fine, except in one case: there is one column in the table with datatype datetime and there are few records in text file having dates like 01/07/1861, 09/08/1865 etc. and the wizard fails to import these type of records giving error "Invalid Date Format"
Can any one assist me?
Thanks and Regards,
Pratik
UPDATE -
The problem is with only date value 08/08/1696.
Even if I try to run simple query like following:
select convert(datetime,'08/08/1696', 101) it gives error like “The conversion of a varchar data type to a datetime data type resulted in an out-of-range value.”
The best thing to do is to import everything to a staging table with all column data types as NVARCHAR or VARCHAR.
Once this is done you can then convert the data easily from string to date.
http://social.msdn.microsoft.com/Forums/en/transactsql/thread/47fc07d2-37fe-4dd8-b57f-3867cd57e2b0
I would only suggest to check the actual format of your data in the source database. In my case I solved the issue by passing nullable datetime2 to date fiels. This worked because the wizard was not reading correctly the source database and it was passing this wrong format (the source database was using datetime2, and the wizard was passing smalldatetime, creating the error).