两个给定日期之间的天数 [英] Number of days between two given dates

查看:108
本文介绍了两个给定日期之间的天数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何严格使用HQL来计算两个日期之间的天数。

How do I calculate number of days between the to dates strictly using HQL alone.

假定 Current_Date Expiry_Date 是从中获取的两个日期数据库。我想计算 Current_Date Expiry_Date 之间的天数。

supposing Current_Date and Expiry_Date are two dates fetched from database. I want to calculate days between Current_Date and Expiry_Date.

此外,如果任何值为 null ,我将如何处理?

Also, How will I handle, if any of the value is null ?

推荐答案

我为我的问题找到了解决方案。

I figured an solution for my issue.

(extract(doy from bp.qhrIqamaexpirDate)-extract(doy from now()))

doy 表示一年中的某一天(1-365/366)。

doy represents The day of the year (1 - 365/366).

bp.qhrIqamaexpirDate : 2013-02-28 00:00:00.0

now() : 2013-03-14 14:53:12.051562

extract(doy from  bp.qhrIqamaexpirDate) : 59, extract(doy from now()) : 73

这篇关于两个给定日期之间的天数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆