获取本月第一天和最后一天的最简单的写法

本文介绍了一段 Delphi 代码,用于计算当前月份的第一天和最后一天的具体日期。通过使用 `StrToDate` 和 `FormatDateTime` 函数,该代码能够方便地获取指定格式的日期字符串。

var
  FirstDay, LastDay: TDateTime;
begin
  FirstDay := StrToDate(FormatDateTime('yyyy-MM-01', Now));
  LastDay := IncMonth(FirstDay) - 1;
  ShowMessage(FormatDateTime('yyyy-MM-01', Now)); //本月第一天
  ShowMessage(FormatDateTime('yyyy-mm-dd',IncMonth(FirstDay) - 1)); //本月最后一天
end;

转载于:https://www.cnblogs.com/JackSun/archive/2010/10/21/1857285.html

仿造下面的代码 delete from subptgoods2 where not exists (SELECT 1 FROM ( select * from ( select subptou2.mid mid0, subptou2.invono invono0, subptou1.date date0, subptou1.vendorid vendorid0, vendor vendor0, model model0, subptou2.sort sort0, color color0, size size0, platsort platsort0, subptou2.qty qty0, subptou2.weight weight0, subptou2.unitpri unitpri0, round(subptou2.qty*subptou2.unitpri,2) amt0, subptou2.mem mem0 from subptou1 inner join subptou2 on subptou2.invono=subptou1.invono left join subvendor1 on subvendor1.vendorid=subptou1.vendorid -- where date_format(subptou1.date,'%Y-%m')=date_format(now(),'%Y-%m') )tb1 where exists (SELECT 1 FROM (select mid1 from ( select max(mid) mid1,sort,model,color,platsort,vendorid from subptou2 inner join subptou1 on subptou2.invono=subptou1.invono group by sort,model,color,platsort,vendorid )tb2)tb3 WHERE tb1.mid0=tb3.mid1 ) )tb4 where tb4.model0=subptgoods2.model and tb4.sort0=subptgoods2.sort and tb4.model0=subptgoods2.model and tb4.color0=subptgoods2.color and tb4.platsort0=subptgoods2.platsort and tb4.vendorid0=subptgoods2.vendorid) 把下面的代码修改一下 "select subptin1.invono, subptin1.date, subptin1.vendorid, vendor, subptou2.model, subptou2.color, subptin2.qty, subptin2.weight, subptin2.unitpri, round(subptin2.qty*subptin2.unitpri,2) amt, subptin2.mem from subptin1 inner join subptin2 on subptin2.invono=subptin1.invono inner join subptou2 on subptou2.mid=subptin2.id inner join subptou1 on subptou1.invono=subptou2.invono left join subvendor1 on subvendor1.vendorid=subptin1.vendorid where date_format(subptin1.date,'%Y-%m')=date_format(now(),'%Y-%m') ORDER BY subptin1.date desc,subptin1.invono desc MYSQL5.5版本 ,请在 源码修改 帮我做一个查询,就是查询 本月内的,相同的 subptin1.vendorid subptou2.model subptou2.color 不同的单价subptin2.unitpri 这个报表有 subptin1.mid值 ,查找最大subptin1.mid值 subptin2.unitpri 因为 相同的 subptin1.vendorid subptou2.model subptou2.color 有可能不同的 subptin2.unitpri 取唯一值,保留 最大subptin1.mid值 subptin2.unitpri
最新发布
08-22
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值