We help IT Professionals succeed at work.
Get Started

What is the Oracle code for converting the format of a date variable?

f19l asked
Last Modified: 2016-02-11

I am trying convert my SQL code into its Oracle equivalent. One part of the original code involves taking the value in a cell, which is today's date, and converting it into the appropriate format within a variable.

Below is an example of the code.

With Selection.ListObject.QueryTable
    .Connection = Conn
    .CommandText = Array(comstring)
    .CommandText = .CommandText + " WHERE (TRAD In ('LSWL'))"
    .CommandText = .CommandText + " AND (INPUTDATE={ts '" & opicsdate & "'})"
    .CommandText = .CommandText + " AND (DETAILIND not In ('FXTR'))"
    .Refresh BackgroundQuery:=False
End With

If I wish to convert into Oracle then I have been informed I would need to change the date line as shown below. I would need to manually type in the relevant date.

.CommandText = .CommandText + " AND (INPUTDATE=to_date('2015/09/03 00:00:00','YYYY/MM/DD HH24:MI:SS'))"

What I would like to do is still be able to keep that opicsdate variable. Is that possible?

Watch Question
Most Valuable Expert 2012
Distinguished Expert 2020
This problem has been solved!
Unlock 2 Answers and 7 Comments.
See Answers
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE