I need to check the day and the month. I'm using Date.Now
.
for example:
if day =9 and month=10 then do action
How can i do that?
The date today is Thursday, October 13, 2022.
Day 287. Day of the year is a number between 1 and 365 (in 2022), January 1 is day 1. After today 78 days are remaining in this year.
In English, the names are Monday, Tuesday, Wednesday, Thursday, Friday, Saturday, and Sunday, then returning to Monday. Such a week may be called a planetary week.
To count days: Assign each day of the week a value between 1 and 7. If your days occur within the same week, subtract the earlier date from the later date. If your days occur in different weeks, add 7 to the later date for each week of difference, and then do the same subtraction.
Use the Day
and Month
properties of a DateTime variable:
Dim currentDate As DateTime = DateTime.Now
If currentDate.Month = 10 AndAlso currentDate.Day = 9 Then
'Do something
End If
The Date
object has a Day
and a Month
property:
Dim today = Date.Today
Dim day = today.Day
Dim month = today.Month
If day = 9 AndAlso month = 10 Then
' do something ...
End If
Note that i've used Date.Today
instead of Date.Now
since you're interested in the date part anyway.
Date.Now.Month and Date.Now.Day. Those are properties on the Date type.
Dim today = Date.Now.Date
If today.Day = 9 AndAlso today.Month = 10 Then ...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With