sql-server - 在数据库表中显示每个月的最后一个工作日。(工作日不包括周六、周日)
问题描述
我想在数据库表中显示每个月的最后一个工作日(不包括周六、周日)。
解决方案
我们使用 pgadmin,我猜它类似于 SQL Server,这是我们使用的查询:
bolReturn = true;
--Get the day of week
SELECT EXTRACT(DOW FROM _start)
Into dayofweek;
--Sataurday
if dayofweek = 6 then
bolReturn = false;
--Sunday
ELSIF dayofweek = 0 then
bolReturn = false;
end if;
--Check against office closing
select count(*) as start
into intCount
from tables.officeclosed where closeddate = _start;
if intCount > 0 then
bolReturn = false;
end if;
return
tables.officeclosed
将包含您知道自己休假的日子,例如假期,并且_start
是您过去的日期。
推荐阅读
- c++ - 谁负责删除 FILE_NOTIFY_INFORMATION.FileName?
- powerbuilder - 保存为数据窗口的csv文件,需要很多时间
- javascript - 如何获取数组中 5 个最小值的索引?
- javascript - 如何自定义剑道反应调度程序?
- android - Android FingerprintManager CryptoObject Cipher init 生物特征认证后的私钥只能使用一次
- sql - 将自动生成的文本框中的数据插入 SQL Server 数据库
- mysql - 默认情况下不执行更改日期时间的 SQL 请求
- docker - 如何在 docker 容器中使用 cron
- reactjs - componentDidUpdate 导致无限循环
- oauth - 通过 SAML 作为 IDP 协议使用 O365 进行 Outlook 身份验证 (SSO) - 资源无效错误