减去90天或3个月 [英] Subtracting 90 days or 3 months
本文介绍了减去90天或3个月的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想创建一个正好是90的日期.添加天数为负值会给我这个错误:
从字符串"02/09/2011"到类型"Long"的转换无效.
I want to create a date exactly 90 earlier. Add days with a negative value gives me this error:
Conversion from string "02/09/2011" to type ''Long'' is not valid.
New Date(Now.AddDays(-90).ToShortDateString)
推荐答案
出现了什么问题:
What''s wrong with:
Dim dt As Date = Now.AddDays(-90)
?
DateTime.Today.DayOfYear-90
DateTime.Today.DayOfYear - 90
如果您将字符串值分配为日期,则会发生此错误.
Date的构造函数没有采用String格式的Date的.请尝试以下方法:
If you are assigning String Value as a Date then this Error occurs.
There is no constructor for Date which take Date in String format as it is.Try this one :
Dim _Date As Date = New Date("2011", 12, "1")
MessageBox.Show(_Date.Month - 3)
希望对您有帮助. :)
I hope it will help you. :)
这篇关于减去90天或3个月的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文