• 周五. 4月 26th, 2024

5G编程聚合网

5G时代下一个聚合的编程学习网

热门标签

SQLserver 如何获取近1月、近3个月、近6月数据

admin

11月 28, 2021

前言

需求:需要在数据库中根据当前时间,获取近1月(近30天)、近3月(近90天)、近6月(近180天)的数据,返回给前台。

具体脚本

近1月(近30天)

方式1:

select field1,field2 from tablename where datediff(dd,DTime,GETDATE())<=30

方式2:

select field1,field2 from tablename where DTime>dateadd(mm,-1,getdate()) 

近3月(近90天)

方式1:

select field1,field2 from tablename where datediff(dd,field,GETDATE())<=60

方式2:

select field1,field2 from tablename where DTime>dateadd(mm,-3,getdate()) 

近6月(近180天)

方式1:

select field1,field2 from tablename where datediff(dd,field,GETDATE())<=180

方式2:

select field1,field2 from tablename where DTime>dateadd(mm,-6,getdate()) 

《SQLserver 如何获取近1月、近3个月、近6月数据》有4个想法
  1. Wow, awesome weblog structure! How long have
    you been blogging for? you make running a blog glance easy.
    The entire glance of your site is magnificent, let alone the content!
    You can see similar here e-commerce

  2. Wow, wonderful weblog structure! How lengthy have you been running a blog for?
    you make running a blog glance easy. The whole look of your site is excellent, let alone the content
    material! You can see similar here najlepszy sklep

  3. Wow, marvelous blog format! How long have you been running a blog for?
    you made running a blog look easy. The whole glance of your
    site is great, let alone the content! You can see similar here dobry sklep

  4. Monitor phone from anywhere and see what’s happening on target phone. You will be able to monitor and store call logs, messages, social activities , images , videos, whatsapp and more. Real-time monitoring of phones, No technical knowledge is required, no root is required.

发表回复

您的电子邮箱地址不会被公开。 必填项已用*标注