Jump to content
We've recently updated our Privacy Statement, available here ×

how to add doulbe quotes "t" to in expression?


dprogrammer

Recommended Posts

Hi, I have a string parameter that will pass a datetime string value as follows. I need to create a dynamic WHERE clause and format that datetime string value and conver it to date.

2009-01-01"t"13:00:00  -given value in the parameter say $P{DTvalue}

My dynamic Where clause parameter that I am adding after my Select statement:

//Select * From TableQ   $P{DynamicDTValue}

" Where Start_Date=to_date(" +$P{DTValue}+", 'yyyy-mm-dd"t"hh24:mi:ss')"

The problem I am having is the double qutoes surrounding t are causing error:

net.sf.jasperreports.engine.JRException: Errors were encountered when compiling report expressions class file:
1. Syntax error on token "t", * expected
                value = (java.lang.String)(" Where Start_Date=to_date(" +((java.lang.String)parameter_DTValue.getValue())+", 'yyyy-mm-dd"t"hh24:mi:ss')");

I must need the double quotes to work it correctly. Any ideas how can I pass the string with double quotes to t ?

Link to comment
Share on other sites

  • Replies 1
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

In general it's a bad idea to take your "date" and convert it to a string which then gets converted in the SQL back to a date for comparison purposes. Comparing a date to a date is a lot safer.

 

But you probably already know that, and you have a reason to break the rules in this case. Assuming that's true...

 

It should be as simple as escaping the double-quote like this:
String1 + ", \'yyyy-mm-dd\"t\"hh24:mi:ss\')");

 

Note: this forum eats escaped characters in weird and annoying ways. So it may be difficult to communicate exactly what we're trying to write. But backslash-doublequote ought to work within a Java string.

 

Regards,
Matt

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...