Jump to content

Use of parameter in DATEPART in SQL query


Lionia1979

Recommended Posts

Hi

 

I have a jasper report fetching data with following query:

 

SELECT datepart(ww, LOGDATE) AS weeks from mc_logs

 

This works. The problem comes when I replace the 'ww' with a parameter like

 

SELECT datepart($P{DATETYPE}, LOGDATE) AS weeks from mc_logs

 

Has anyone tried this or have a workaround?

Link to comment
Share on other sites

  • Replies 2
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

I was looking for the same thing... found another thread and this works for me now...

 

SELECT a,b,c,d

FROM table_t

WHERE create_timestamp <= DATE('$P!{parameterName}') AND create_timestamp > (DATE('$P!{parameterName}')-INTERVAL '6 days')

ORDER BY a

 

[This is PostgreSQL SQL]

 

For me the trick was to add the '!' mark

$P!{ParameterName}

 

I trust this to be of assistance!

have a great day!

NiPo.:silly:

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...