SQL SERVER ORACLE Character Date Conversation sysdate getdate()

Aynı değerler için date-text (character) ve text-date dönüşümlerini hem MS SQL Server hem de Oracle için yazacağım. Böylece rahatca kıyaslama yapabilirsiniz.

Same text (character) and date conversations were applied on SQL Server and Oracle. In this way you can compare codes easily.

Convert text to Date type in Oracle, Cast character to Date type in Oracle, Convert character to Date in Oracle. Karakteri, date türüne çevirme Oracle. Belirli tarihi date e çevirme oracle. To_date kullanımı:

SELECT TO_DATE('15.03.2018','DD.MM.YYYY') as date_oracle FROM dual;
SELECT TO_DATE('2018-03-15','YYYY-MM-DD') as date_oracle FROM dual;
SELECT TO_DATE('20180315','YYYY-MM-DD') as date_oracle FROM dual;

Convert text to Date type in SQL Server, Cast character to Date type in sql server, Convert character to Date in sqlserver. Karakteri, date türüne çevirme sqlserver. Belirli tarihi date e çevirme oracle:

SELECT convert(date,'15.03.2018',104) as date_mssql --text format: DD.MM.YYYY
SELECT convert(date,'2018-03-15',23) as date_mssql --text format: YYYY-MM-DD
SELECT convert(date,'20180315',112) as date_mssql; --text format: YYYYMMDD

getdate() in oracle is sysdate. getdate() Oracle da sysdate olarak geçiyor. sysdate in SQL Server is getdate(). sysdate Sql Server’da getdate() olarak geçiyor.
sysdate : oracle – current date-time
getdate() : sql server – current date-time

Date to Character in Oracle, formatting sysdate, cast date to text in oracle. Date tipini karaktere çevirme Oracle. Oracle Date Maske kullanımı:

SELECT TO_CHAR(sysdate,'DD.MM.YYYY') as character_oracle FROM dual;
SELECT TO_CHAR(sysdate,'YYYY.MM.DD') as character_oracle FROM dual;
SELECT TO_CHAR(sysdate,'YYYYMMDD') as character_oracle FROM dual;

Date to Character in SQL Server, formatting getdate(), cast date to text in oracle. Date tipini karaktere çevirme Oracle:

SELECT convert(varchar, getdate(), 104) as character_mssql; -- 27.01.2021
SELECT convert(varchar, getdate(), 23) as character_mssql; -- 2021-01-27
SELECT convert(varchar, getdate(), 112) as character_mssql; -- 20210127
date to character in mssql

In date conversation, always you should use date format. Don’t use automatic conversation. Otherwise your codes may get error in different environment.

Tarih dönüşümlerinde formatlamayı(maskelemeyi) mutlaka kullanmak gerekiyor. Otomatik tür dönüşümü yaptırmayın. Çünkü kodunuz kod farklı ortamdan çağırılırsa hata alabilir.

Leave a Reply

Your email address will not be published. Required fields are marked *