我想显示将在表中特定日期范围内的文本,现在有两个不同的列,分别是从日期和日期到现在,我想在日期之间显示显示文本... [英] i want to display a text which will be in particular date range in a table am having two different columns as from date and todate now i want to display the display text in between the dates how...

查看:52
本文介绍了我想显示将在表中特定日期范围内的文本,现在有两个不同的列,分别是从日期和日期到现在,我想在日期之间显示显示文本...的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在表格中显示特定日期范围内的文本,现在有两个不同的列,分别是从日期和日期到现在,我想在日期之间显示显示文本,我该如何编写查询
编辑-pashad

i want to display a text which will be in particular date range in a table am having two different columns as from date and todate now i want to display the display text in between the dates how do i write query for this
Edit-pashad

SELECT n.noticetext ,DATEDIFF(DD,n.PeriodFrom,n.PeriodTo) from tbl_Master_NoticeBoard as n inner join tbl_Master_Employee as e on e.Cid=n.DisplayTo where e.EmployeeId='j126' 

推荐答案

您好,请尝试以下操作:添加@FromDate& @ToDate参数用于日期选择&按照查询.
Hi, Try this: add @FromDate & @ToDate parameters for the date selection & follow the query.
SELECT 
noticetext ,
FROM tbl_Master_NoticeBoard 
INNER JOIN tbl_Master_Employee ON Cid = DisplayTo 
WHERE EmployeeId='j126'
AND PeriodFrom >= @FromDate AND PeriodTo <= @ToDate


是什么意思?
Do you mean?
SELECT CONVERT(NVARCHAR, n.PeriodFrom & ' - ' & n.noticetext  & ' - ' & n.PeriodTo) AS [OneColumn]
FROM tbl_Master_NoticeBoard as n inner join tbl_Master_Employee as e on e.Cid=n.DisplayTo
WHERE e.EmployeeId='j126' 



结果:



Result:

OneColumn<br />
2011/05/05 - Travel to Berlin - 2011/05/07



阅读有关转换 [



Read more about CONVERT[^]


这篇关于我想显示将在表中特定日期范围内的文本,现在有两个不同的列,分别是从日期和日期到现在,我想在日期之间显示显示文本...的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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