Date format is changing in SQL developer - sql

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.

Related

I try to convert date format in sql but it still doesn't work

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').

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

What is standard date time string format for SQL query for insering data in datetime columns?

Today I faced a problem while porting an SQL server database to H2DB. The SQL queries I had written to insert date time, wasn't working on H2DB. i.e '26-Jun-2019 01:00:00' gave exception on H2DB. My question is what is standard format for inserting date time which is database independent?
The standard format as defined by the SQL standard is the ISO format, prefixed with the keyword DATE, e.g.
DATE '2019-06-26'
or for a timestamp:
TIMESTAMP '2019-06-26 17:42:00'
However not all database products support the SQL standard in that regard, so you will most probably not find one single format that will work across all database products.

Change Datetime format in Microsoft Sql Server 2012

Hi i want to change the default datetime type in sql server. I have already table who has rows and i dont want to delete them. Now the datetime format that had rows is: 2015-11-16 09:04:06.000 and i want to change in 16.11.2015 09:04:06 and every new row that i insert i want to take this datetime format.
SQL Server does not store DATETIME values in the way you're thinking it does. The value that you see is simply what the DBMS is choosing to render the data as. If you wish to change the display of the DATETIME type, you can use the FORMAT() built-in function in SQL Server 2012 or later versions, but keep in mind this is converting it to a VARCHAR
You can get the format you desire via the following:
SELECT FORMAT(YourDateField, N'dd.MM.yyyy HH:mm:ss')
There is no such thing as format of the DATETIME data type, it has no format by nature, formatted is the text representation you can set when converting to VARCHAR or some visualization settings of the client / IDE.
If you, however, want to be able to insert dates using string representations that are alternatively formatted (i.e. control the way string input is parsed to datetime type) you can check SET DATEFORMAT - as explained in the remarks section this will not change the display representation of date fields / variables.
SQL serve provide wide range of date formatting function or way by using that user can change date format as per his requirement.
Some of are giver bellow.
CONVERT(VARCHAR(19),GETDATE())
CONVERT(VARCHAR(10),GETDATE(),10)
CONVERT(VARCHAR(10),GETDATE(),110)
CONVERT(VARCHAR(11),GETDATE(),6)
CONVERT(VARCHAR(11),GETDATE(),106)
CONVERT(VARCHAR(24),GETDATE(),113)

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.