SQLLDR Oracle Data Import, Date Format = yyyy-mm-dd - sql

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'

Related

AsterixDB unable to import datetime when importing from CSV file (SQL)

I am attempting to load a database from a CSV file using AsterixDB. Currently, it works using only string, int, and double fields. However, I have a column in the CSV file that is in DateTime format. Currently I am importing them as strings, which works fine, but I would like to import them as the SQL DateTime data type. When I try changing my schema and reimporting I get the following error:
ERROR: Code: 1 "org.apache.hyracks.algebricks.common.exceptions.NotImplementedException: No value parser factory for fields of type datetime"
All entries are in this format 02/20/2010 12:00:00 AM.
I know this isn't exactly inline with the format specified by the Asterix Data Model, however, I tried a test line with the proper format and the error persisted.
Does this mean AsterixDB cant parse DateTime when doing mass imports? And if so how can I get around this issue?
Any help is much appreciated.
Alright, after discussing with some colleagues, we believe that AsterixDB does not currently support DateTime parsing when mass importing. Our solution was to upsert every entry in the dataset with the parsing built into the query.
We used the following query:
upsert into csv_set (
SELECT parse_datetime(c.Date_Rptd, "M/D/Y h:m:s a") as Datetime_Rptd,
parse_datetime(c.Date_OCC, "M/D/Y h:m:s a") as Datetime_OCC,
c.*
FROM csv_set c
);
As you can see we parse the strings using the parse_datetime function from the AsterixDB Temporal Functions library. This query intentionally doesn't erase the column with the DateTimes in string format, although that would be very simple to do if your application requires it. If anyone has a better or more elegant solution please feel free to add to this thread!

changing dateformat sql

On loading a date column from salesforce, I receive it in this format: 2017-01-31 22:00:00. I want convert this to the german format and load into sql table without time.
Also, which datatype should I initialize in creating column in table?
try using the Convert function if you're using MSSQL
select Convert(nvarchar(10),GETDATE(),101)
This will create mm/dd/yyyy
if you need more samples please look at w3schools to convert time in different formats
https://www.w3schools.com/sql/func_sqlserver_convert.asp

How to format yyyy-MMMM in Hive?

I'm trying to format date column ("craeteddate") as yyyy-mmmm, i.e.: 2017-November.
select unix_timestamp(createddate, 'yyyy-MMMM') from cc_vw_case
This SQL throws "Bad date/time conversion format: yyyy-MMMM".
Is it possible format as yyyy-MMMM in Hive? I'm using Cloudera Hadoop.
If your input value is a Unix timestamp, then you'll need to use FROM_UNIXTIME instead of UNIX_TIMESTAMP. This gets the correct answer in Hive:
SELECT FROM_UNIXTIME(1510218382, 'yyyy-MMMM')
Answer: 2017-November
unix_timestamp is trying to parse your column, not format it.
Probably throws an error because it is not in the given format
You need to use a combination of from_unixtime(unix_timestamp(col, "format from"), "format to") to convert between datetimes

Date format is changing in SQL developer

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.

Excel Date Field Import Problem in Oracle SQL Developer

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.