在2个日期之间查找日期

我在这里试图查找def callbackTo2(*args): screen_manager.current = 'main_screen' class ScreenOne(Screen): def __init__(self,*args): super(ScreenOne,self).__init__(name='ScreenOne') self.timer = None def on_enter(self,*args): print('on_enter ScreenOne:') # start the timer for 30 seconds self.timer = Clock.schedule_once(callbackTo2,30) def on_leave(self,*args): # cancel the timer self.timer.cancel() self.timer = None def on_touch_down(self,touch): if self.timer is not None: self.timer.cancel() # reset the timer self.timer = Clock.schedule_once(callbackTo2,30) return super(ScreenOne,self).on_touch_down(touch) campStartDate之间的日期,但是我无法设置静态日期,我只是想获取campcampDate和camEndDate之间的日期

我已经尝试过了,但是我不知道如何以正确的方式获取数据:

campEndDate

CrudRepository类:

public class Bulk_repository {
@Id
   @GeneratedValue(strategy=GenerationType.AUTO)
   @Column(name = "id")
   private long id;

   @Column(name = "camp_start_date")   
   private Date campStartDate;

   @Column(name = "camp_end_date")
   private Date campEndDate;
}

应用程序:

public interface Bulk_repositoryRepository extends CrudRepository<Bulk_repository,Long> {

List<Bulk_repository>findAllByStatusAndCampTypeAndCampStartDateLessThanEqualAndCampEndDateGreaterThanEqual(int status,int campType,Date campStartDate,Date campEndDate);
Bulk_repository findById(long id);
}
tfqguo 回答:在2个日期之间查找日期

考虑 campStartDate 总是小于 campEndDate ,如果您要查找某个日期的记录,而该日期的日期介于两者之间,认为比较不正确,应按如下所示更改条件

public interface Bulk_repositoryRepository extends CrudRepository<Bulk_repository,Long> {

List<Bulk_repository>findAllByStatusAndCampTypeAndCampStartDateGreaterThanEqualAndCampEndDateLessThanEqual(int status,int campType,Date campStartDate,Date campEndDate);
Bulk_repository findById(long id);
}

编辑:

如果您不想传递日期,那么JPQL可以为您提供帮助,请尝试更改存储库中的方法签名,例如

public interface Bulk_repositoryRepository extends CrudRepository<Bulk_repository,Long> {

@Query("SELECT b FROM Bulk_repository b WHERE b.status = :status and b.campStartDate >=CURRENT_DATE and b.campEndDate <= CURRENT_DATE)
List<Bulk_repository>findAllByStatusAndCampTypeAndCampStartDateGreaterThanEqualAndCampEndDateLessThanEqual(@Param("status") int status);
Bulk_repository findById(long id);

}
本文链接:https://www.f2er.com/3123415.html

大家都在问