日期小于或等于 [英] less than or equal in date
本文介绍了日期小于或等于的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
您好,
我想比较两个日期值(特定月份),但我得到一个错误'运算符< =未定义类型date和boolean'
和代码
私人 Sub Button1_Click( ByVal sender As System。对象, ByVal e As System.EventArgs)句柄 Button1.Click
Dim dt As 新 日期
dt = 日期 .Parse(DataGridView1 .CurrentCell.Value)
TextBox1.Text = DataGridView1.CurrentCell.Value.ToString
If (日期。今天< =(日期 .Today.AddMonths( 1 )= dt))_ ' < -error here
和( Date .Today< = DataGridView1.CurrentCell.Value)然后
DataGridView1.CurrentCell.Style.BackColor = Color.Beige
MessageBox.Show( int, int)
结束 如果
结束 Sub
我想检查date.today何时等于或小于date.today.addmonth(1)的1个月但是要检查整个31天的时间。
解决方
语法不正确。通过语法此处 [ ^ ]。
试试如果(Date.Today< = dt.AddMonths(1))
错误已更正但当我检查的日期大于1个月它还弹出消息框,我想要做的是:我的未来日期是当前日期是未来给定日期之前的一个月和本月期间,直到将来的给定日期不会提前弹出消息框而不是之后未来的给定日期。
Hello,
I want to make a compare to 2 date values (months to be specific), but I get an error 'operator <= is not defined for types date and boolean'
and the code
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim dt As New Date
dt = Date.Parse(DataGridView1.CurrentCell.Value)
TextBox1.Text = DataGridView1.CurrentCell.Value.ToString
If (Date.Today <= (Date.Today.AddMonths(1) = dt))_'<-error here
And (Date.Today <= DataGridView1.CurrentCell.Value) Then
DataGridView1.CurrentCell.Style.BackColor = Color.Beige
MessageBox.Show("int", "int")
End If
End Sub
I want to check when the date.today is equal or less than 1 month of the date.today.addmonth(1) but to check the whole period of 31 days.
解决方案
The syntax is incorrect. GO through the syntax here[^].
TryIf (Date.Today <= dt.AddMonths(1))
the error corrected but when I check for a date greater than 1 month it also pop up the messagebox, what I want to do is : I have a future date when the present date is a month before the future given date and this month period until the future given date to pop up the messagebox no earlier and not after the future given date.
这篇关于日期小于或等于的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文