date sring格式用于过滤记录 [英] dates sring formats for filtering records

查看:94
本文介绍了date sring格式用于过滤记录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨!我正在尝试从两个DateTimePickers中过滤记录,一个用于初始日期,另一个用于最终日期,当您单击按钮时,过滤器已完成,显示的记录是日期范围内的记录。为此,我定义了两个公式:最初的一个是:Date(1997,04,02)和最后一个:Date(1998,04,10)然后是一个记录选择公式:({Orders.Order Date}> ; {@inicial })和({Orders.Order Date}< {@ final })

Hi! I'm trying to filter records from two DateTimePickers, one for the initial date and the other for the final, when you click a Button the filter is done and the records shown are those in the dates range. To do that I defined 2 formulas: the initial one is this: Date (1997, 04, 02) and the final one: Date (1998, 04, 10) and then a record selection formula: ({Orders.Order Date} > {@inicial}) And ({Orders.Order Date}< {@final})

这是有效的,当我运行没有日期过滤的报告时,会显示该记录日期范围。

This works and when I run the report with no dates filtering the records are displayed for that dates range.

现在我添加了Button和2个datetimepickers,这是点击按钮的代码:

 Now I added the Button and the 2 datetimepickers and this is the code for the click button :

Private Sub Print_Click(ByVal sender As System.Object,ByVal e As System.EventArgs)处理Print.Click
Dim myReport As New CustomReportClass
myReport.DataDefinition.FormulaFields(" initial")。Text =" CDate(" + String。格式("yyyy,MM,dd",DateTimePicker1.Text)+")"
myReport.DataDefinition.FormulaFields(" final")。 =" CDate(" + String.Format(" yyyy,MM,dd",DateTimePicker2.Text)+")"

Private Sub Print_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Print.Click
        Dim myReport As New CustomReportClass
        myReport.DataDefinition.FormulaFields("initial").Text = "CDate(" + String.Format("yyyy,MM,dd", DateTimePicker1.Text) + ")"
       myReport.DataDefinition.FormulaFields("final").Text = "CDate(" + String.Format("yyyy,MM,dd", DateTimePicker2.Text) + ")"       

myCrystalReportViewer.ReportSource = myReport
End Sub
 myCrystalReportViewer.ReportSource = myReport
    End Sub

推荐答案

你测试了你的字符串( "CDate(" etc.)以确保它的格式符合预期?你可以让这些字符串自行返回,这样你就可以确认你的语法是否正确吗?
Have you tested your string ("CDate(" etc.)  to be sure that it's being formatted as expected?  Can you just have those strings return themselves so you can confirm that your syntax is correct?


这篇关于date sring格式用于过滤记录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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