Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

How to set date parameter in the native query

Zaheer ali
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
July 16, 2022

I have created a query like this.

String date = "01/01/2021";
String date2  = "01/05/2021"
Query query = em.createNativeQuery("select * .... From .... Date between ? And ?");

I want to set parameters as the two dates in this format "dd/MM/YYYY".

When I tried to set the string dates like this it is giving me an error. Can anyone help me how to do that ?

2 answers

3 votes
Nic Brough -Adaptavist-
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
July 16, 2022

Welcome to the Atlassian Community!

Your code is not JQL, can we assume you are trying to replicate this in JQL?

If so, then the basic JQL you can start with will do "show me issues created between date X and date Y".  This comes out as

created >= date X and created <= date Y

For an example with fixed dates, "show me the last working month (at the time of me writing this), you would say

created >= "2022/06/01" and created <= "2022/06/30"

If you're not trying to convert this to JQL, then you'll need to explain what you're running it in and how you're going to be constructing the REST call to Jira to do the search.

0 votes
Pramodh M
Community Champion
July 16, 2022

Hi @Zaheer ali 

Welcome to the community 🙂

Can you please explain if you are trying to get the issues from JQL or any scripting method?

If it's Scriptrunner, here's the ref

https://docs.adaptavist.com/sr4js/latest/features/jql-functions

Let me know the exact context

Thanks,

Pramodh

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events