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 8745449
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T12:00:55+00:00 2026-06-13T12:00:55+00:00

I am wondering how to query the database using the model in play 2.0

  • 0

I am wondering how to query the database using the model in play 2.0 with a query like the one I listed below. I didn’t see an option to pass in direct sql into the play framework 2.0.

I am trying to get a list of the expenses from a particular month.

SELECT * FROM Expensesdb.expense
WHERE month(expense.purchase_date) = 01

The option I see is to query for all the expenses and then parse each one for the month they are listed using the Date object.

I think there should be an efficient way, I can’t seem to find a way to do this using ebean with Java play framework 2.0 to perform this query.

Update

Thanks Nico, I tried the exact code you have, with DateTime and I tried to use the code below, it doesn’t return any Expenses. Am I doing something wrong?

    Calendar calendar = Calendar.getInstance();
    calendar.set(2012, 0, 01);

    Date startDate = calendar.getTime();
    calendar.set(2012, 0, calendar.getActualMaximum(Calendar.DAY_OF_MONTH));

    Date endDate = calendar.getTime();
    List<Expense> expenses = find.where().between("purchaseDate", startDate, endDate).findList();
    return expenses;
  • 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-06-13T12:00:55+00:00Added an answer on June 13, 2026 at 12:00 pm

    I see two options:

    1 – Using Ebean mapping

    The idea is to search the expenses between the beginning and the end of the month, something like:

    Datetime firstDayOfMonth= new Datetime().withDayOfMonth(1);
    Datetime lastDayOfMonth = new Datetime().dayOfMonth().withMaximumValue();
    return finder.where()
        .between("purchaseDate", firstDayOfMonth, lastDayOfMonth).findList();
    

    2 – Using RawSQL

    For this, please take a look at the Ebean documentation.

    The main drawback of raw sql is that this code will not be portable for different SQL servers (if you don’t plan to use several db engine, it will not matter).

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

Sidebar

Related Questions

I'm wondering how to query a database using an array, like so: $query =
hey, I'm wondering how to retrieve data from my database using php to get
I have an jQuery ajax database query and Im wondering how I can maybe
I've been always wondering how mutiple rows are selected from the database and one
Wondering if it's possible to create a dynamic linq query using linq to objects.
I'm developing a PHP web app using a MySQL database. I'm wondering what is
Just wondering how the following sql query would look in linq for Entity Framework...
I'm wondering how I would issue a query from a PDO and have an
Just wondering if someone could help me with a very simple SQL query. I
3I was just wondering if this type of query is even possible. If so,

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.