?
Solved

Oracle to PL/SQL conversion

Posted on 2002-05-02
4
Medium Priority
?
579 Views
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:
'dd'
'MMYYHH24MISS'

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

Thanks In Advance.

0
Comment
Question by:nibeditas
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 143

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 200 total points
ID: 6988204
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 ...

for 'MMYYHH24MISS':
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...

CHeers






0
 
LVL 143

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 6988209
Note that there exist dedicated topics to MS SQL Server and oracle here:
http://www.experts-exchange.com/jsp/qList.jsp?ta=mssql
http://www.experts-exchange.com/jsp/qList.jsp?ta=oracle

CHeers
0
 
LVL 54

Expert Comment

by:nico5038
ID: 7515086

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.

PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER !

Nic;o)
0
 

Expert Comment

by:Jgould
ID: 7548142
Question has been closed as per recommendation

JGould-EE Moderator
0

Featured Post

Get real performance insights from real users

Key features:
- Total Pages Views and Load times
- Top Pages Viewed and Load Times
- Real Time Site Page Build Performance
- Users’ Browser and Platform Performance
- Geographic User Breakdown
- And more

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Although it can be difficult to imagine, someday your child will have a career of his or her own. He or she will likely start a family, buy a home and start having their own children. So, while being a kid is still extremely important, it’s also …
This article will inform Clients about common and important expectations from the freelancers (Experts) who are looking at your Gig.
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…
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…

762 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