Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7622053
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T04:21:19+00:00 2026-05-31T04:21:19+00:00

I have one ‘ Log ‘ entity which contains information about temperature. I’m trying

  • 0

I have one ‘Log‘ entity which contains information about temperature.
I’m trying to build a report which have two fields only:

quantity : this field will tell how much my search should look
interval : minutes, hours, days, months, years (this field tells me how much is the interval of the search

This is my Log entity:

public class Log implements Serializable {
    private static final long serialVersionUID = 1L;

    @Id
    @GeneratedValue(strategy=GenerationType.IDENTITY)
    private Integer id;

    private Timestamp time;

    private String value;
    // getters and setters ...

So when the user inform like 1 minute I should look for the last minute (or 60 records at least).

Or if 1 month I should get all the data from the last month.

I’m trying something like this:

log.time < CURRENT_TIMESTAMP AND log.time > :param

But how can I specify to minutes, hours ? What I mean is how can be more specific in my query ?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T04:21:21+00:00Added an answer on May 31, 2026 at 4:21 am

    If the time unit is “days”:

    Calendar now = Calendar.getInstance();
    now.add(Calendar.DAY_OF_MONTH, -quantity);
    Date param = now.getTime();
    

    Keep your query as is, and bind param to the :param request parameter.

    For other intervals, do the same, but with the appropriate Calendar field (HOUR_OF_DAY, MINUTE, etc.) instead of Calendar.DAY_OF_MONTH.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i have one table, which contains that fields mid , email 1 , 'user_a@...'
I have one server which has nothing but xls log files. Each file is
i have one csv file which contains library group and it's data... group consider
I have one view ,view contains two buttons and one gallery. Gallery view pleased
I have one tabview which contain two different tab(subject and chapter) and i need
I have one std::list<> container and these threads: One writer thread which adds elements
I have one application which uses the standard .NET forms authentication cookie, now I
I have one aspx page with some controls. Also i have one DIV which
I have one server and three clients in which a windows service is running
i have one 'C' 'DLL' which can take structures as input, i have to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.