如何从今天起获取最近5条记录的数据 [英] how to fetch data last 5 records from today date

查看:64
本文介绍了如何从今天起获取最近5条记录的数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想要从今天开始的最后5个记录日期。

在该表中记录员工转移明智的工作清单。例如,一个人工作一天,第二天他不工作,第二天他正在工作。这将适合每一位员工。我需要从今天起最后5天内没有工作的结果集。





SQL SERVER

I want last 5 dates of records from today date.
In that table records employees shift wise working list.for example one person working one day and next day he is not working and next day he is working.it will suitable for each and every employees. i need the result set who r all not working for last 5 days from today date.


SQL SERVER

推荐答案



检查这个希望这会对你有帮助。



Hi,
Check this hope this will help you.

    -- this sample query to display today and 5 days before from today
 select getdate(),DATEADD(dd,-5,getdate())     
                                                              
-- This sample query will return result between 5 days
SELECT * FROM YourTable_Name
WHERE
YOURDateColumn BETWEEN  DATEADD(dd,-5,getdate()) and getdate()


这篇关于如何从今天起获取最近5条记录的数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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