I have an Excel file (which has data imported from Oracle 10G Database) one of the fields is a
Date Filed which has values like 28-JAN-11 03.25.11.000000000 PM ( Date field is Oracle Time
Stamp(6) in Database )
When I am trying to Import that Excel file to another Oracle 10 G database (for another database/application), I get an error because the data field is not being recognized by Oracle 10G --> Import is being done by ORACLE SQL Developer (Table (field) has TIMESTAMP(6) as the datatype)
How can I import that field? For time being I made the TIMESTAMP to VARCHAR2 and its working but I could not convert that to Date field again in C# CODE ( it says not a valid date type).
You likely need to change your SQL Developer settings.
Tools->Preferences->Database->NLS
Modify the Timestamp Format field to conform to the data format in your Excel spreadsheet. Not how it appears in the first database, but what it looks like in your spreadsheet. For example, in my instance, the data in Excel was:
ID DT
1 05/19/2011 10:16 PM
I changed the format in preferences to MM/DD/YYYY HH:MI AM
and was able to import successfully, after initially getting the same error you reported before changing preferences.
You may want to change the way your data is imported into Excel originally if you need more precision from your time values.
During the import wizard process (column definition screen), select the date type field on the left panel under 'Source Data Columns' and type in the expected format in the 'Format' text field. For example, MM/DD/YYYY or whatever the date format is in your import file for that field.
Related
I use the CONVERT() function to trying convert the date format like DD/MM/YYYY with code 103 when I query database, and nothing happens. The data field still displays default format with YYYY/MM/DD.
UPDATE STAFF
SET BIRTH = CONVERT(smalldatetime,'26/08/1900',103)
WHERE ID = 'SF01'
How can I fix this problem ? I'm a newbie so i don't know lots of SQL
Avoid formatting dates in your database, it should be done in the application that queries the data. But IF you still need to do it in your database for whatever reason:
If you want to store the date in the DD/MM/YYYY format in your table then you can do 2 things,
Change your column data type to varchar(not ideal and you should try avoiding this method)
Change the regional settings on the machine running SqlServer and keep it as a date type (this is somewhat useless if you plan on querying data from another app as the app will probably format the date to its local format).
In case you decide to store it as varchar you will need to use the Format function when inserting or updating like this: Format(MyDate, 'DD/MM/YYYY').
I have a .csv export of data where there's something "wrong" with how MS Access sees it when it's a linked data source. MS Access refuses to see them as date fields, and gives me a #NUM! error if I try to force it. However if I import it as a regular table or open it in MS Excel, the date field works fine. As such my date fields are stuck as short text fields in the linked .csv, which prevents me from sorting by a date range.
Is it possible to use a query to change the data type of a field? Short text field goes in one side, date/time (as recognized by MS Access) comes out the other?
I need to import the excel data into oracle database through SQL developer. I have change the date format in excel to the standard oracle format(DD_MON_YYYY HH:MI:SS AM). But while importing in SQL developer this date format is not reflecting, it is giving original date format as there in excel before I changed the format. How can I change the format?
Excel data:
In SQL developer:
As for my knowledge, your import is all right. Importance of the date format is to identify the date field as a date field when you are importing the data to database. After the import, database keep the date values in a default date format. So when you are retrieving the data, you have to specify the date format in your query to get what you want. In other words, use a query to get the data in the database.
Ex:
select to_date(date_field,'DD_MON_YYYY')
from table_name
You just need to change the data format in the SQL Developer preferences, tools > preferences > database > NLS
This will set the default format for displaying dates. You can always get it exactly the way you want for your queries by doing what +Asanga shows.
I have the following Excel Workbook:
https://meocloud.pt/link/7cb3ef48-7556-4d36-ab9a-c247d3f7b29d/FichasTeste.xls/
It's formatted to be imported to a SQL Database. The server has the following details:
As you can see the mapping is correct in the importer
When i try to import the excel file, the status is always the same, no matter the modifications i do to the columns with the Date.
242: The conversion of a varchar data type to a datetime data type resulted in an out-of-range value.
3621: The statement has been terminated.
What should i modify so that those rows can be imported without having that error?
Excel stores dates as integers, if you change the excel field to TEXT you'll see that, but I'm not sure why you're having this problem, you should be able to direclty import from Excel and have dates preserved, at least you can using SQL's import wizard as well as SSIS.
One workaround is using the TEXT() function in Excel to get your date into an acceptable format:
=TEXT(F2,"yyyy-mm-dd")
I like importing from Excel using OPENROWSET(), but that requires some additional setup and has it's own drawbacks:
SELECT *
FROM OPENROWSET('Microsoft.ACE.OLEDB.12.0', 'Excel 12.0;Database=C:\YourExcelFile.xls', [Sheet1$])
I am trying to import data from a flat file into Oracle 11gr2 using SQLLDR, and i have 3 columns with date formats like "yyyy-mm-dd". Oracle keeps throwing errors when I try to import the data like this. Is there a quick solution to just import the data in this format? I would prefer to not have to change the format of the data in the file since it is very large.
Here is an example of the error listed in the log.ct:
Record 51: Rejected - Error on table LINEITEM, column L_SHIPDATE.
ORA-01861: literal does not match format string
Thanks!
Trying casting the date format as mentioned below, in your control card (Control file)
YourColumn DATE "YYYY-MM-DD"
Set the environment setting NLS_DATE_FORMAT
#>export NLS_DATE_FORMAT='YYYY-MM-DD'