按日期范围

编程入门 行业动态 更新时间:2024-10-25 22:34:03
本文介绍了按日期范围的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

伙计们, 我希望这段代码在日期选择器中显示当前选择日期,但不会,但是如果我选择另一个复选框,它将显示所有交易,但是当我要选择"bydate"复选框时,它将不显示当前的选择日期,有人可以帮助我吗:D

Guys, I want this piece of code to display the current pick date in the date picker but it won''t but it display all the transaction if I choose the other check box but when I want to choose the bydate checkbox it won''t display the current pick date can anyone help me with this please :D

ElseIf Me.ListBox1.Text = "Stock - IN" Then If Me.chkAll.CheckState = CheckState.Checked Then xSQL = "SELECT * FROM po" Else xSQL = "SELECT * FROM po WHERE PODate>" & "#" & Format(Me.dtFrom.Value, "MM/dd/yyyy") & "#" & "" & _ " AND PODate<" & "#" & Format(Me.dtTo.Value, "MM/dd/yyyy") & "#" & ";" End If If frmMain.PrintPO(xSQL) = True Then frmReportViewer.strReport = "PO" frmReportViewer.Show() End If ElseIf Me.ListBox1.Text = "Stock - OUT" Then If Me.chkAll.CheckState = CheckState.Checked Then xSQL = "SELECT * FROM sales" Else xSQL = "SELECT * FROM sales WHERE SalesDate>" & "#" & Format(Me.dtFrom.Value, "MM/dd/yyyy") & "#" & "" & _ " AND SalesDate<" & "#" & Format(Me.dtTo.Value, "MM/dd/yyyy") & "#" & ";" End If

推荐答案

几件事; 1)使用SQL查询时,过去一直困扰着日期,所以我总是像``2010-Sep-10''这样过去日期 2)我注意到在SQL文本中您在右边添加了"? 您是否已将SQLtext转储到输出窗口以查看查询文本的确切样子? 我将上面的语句写为; A couple of things; 1) I have been troubled with dates in the past when working with SQL queries, so I always past dates in like ''2010-Sep-10'' 2) I notice in the SQL text you are adding a "" to the right? Have you dumped the SQLtext to the output window to see exactly what the query text looks like? I would write the statement above as; xSQL = "SELECT * FROM sales WHERE SalesDate > '" & Format(Me.dtFromValue, "yyyy-MMM-dd") & "' AND SalesDate < '" & Format(Me.dtTo.Value, "yyyy-MMM-dd") & "';"

另外,您可能想看看如何创建参数化查询.

Also, you may want to look at creating paramaterised queries.

更多推荐

按日期范围

本文发布于:2023-10-28 23:13:45,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1538045.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:按日

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!