Oracle to PL/SQL conversion

Posted on 2002-05-02
Last Modified: 2010-04-17
I am currently working on the conversion of PL/SQL script to T-SQL. I have certain issues that have come up correspondingly.

The To_char function in Oracle can be converted to T-sql by using convert. But Convert needs three argumemnts when date has to be converted to character.

for example:

to_char(sysdate,'dd-mon-yyyy')in Oracle can be replaced with Convert(char,getDate(),106). Here 106 represents the style of the date format 'dd-mon-yyyy'.

The problem is I have a pl/sql script with the following date formats:

I would like to know what are the corresponding Style numbers for the same in T-sql.

Thanks In Advance.

Question by:nibeditas
  • 2
LVL 142

Accepted Solution

Guy Hengel [angelIII / a3] earned 50 total points
Comment Utility
For 'dd':
select convert( char(2), GetDate(), 103)
Note that you need to convert to char(2), this will strip of the rest of the style 103 (dd/mm/yy). Now, you could by this also use other styles ...

This one is more tricky, as omitting the separators and the spaces etc needs to be done:

select substring( replace( replace(replace( convert (varchar(19), getdate(), 120) , ':', ''), '-', ''), ' ', '') , 5,15)

Now, as you can see, the SQL Server functions convert are not that flexible as Oracle's to_char function...


LVL 142

Expert Comment

by:Guy Hengel [angelIII / a3]
Comment Utility
Note that there exist dedicated topics to MS SQL Server and oracle here:

LVL 54

Expert Comment

Comment Utility

No comment has been added lately, so it's time to clean up this TA.
I will leave a recommendation in the Cleanup topic area that this question is:
 - Answered by: angelIII
Please leave any comments here within the
next seven days.



Expert Comment

Comment Utility
Question has been closed as per recommendation

JGould-EE Moderator

Featured Post

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Fix45 challenge 15 82
scoreUp challenge 14 47
countPairs challenge 7 57
Windows Service to Receive TCP Packets 4 27
I know it’s not a new topic to discuss and it has lots of online contents already available over the net. But Then I thought it would be useful to this site’s visitors and can have online repository on vim most commonly used commands. This post h…
A short article about problems I had with the new location API and permissions in Marshmallow
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

728 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now