Check day and month of current date

I need to check the day and month. I am using Date.Now .

eg:

if day = 9 and month = 10, then do action

How can i do this?

+4
source share
5 answers

Use the Day and Month properties of the DateTime variable:

 Dim currentDate As DateTime = DateTime.Now If currentDate.Month = 10 AndAlso currentDate.Day = 9 Then 'Do something End If 
+8
source

The Date object has the Day and 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 used Date.Today instead of Date.Now , since you are still interested in the date part.

+3
source

Date.Now.Month and Date.Now.Day. These are properties in a date type.

+2
source
 Dim today = Date.Now.Date If today.Day = 9 AndAlso today.Month = 10 Then ... 
+1
source
 Date.today.day Date.today.month 
0
source

All Articles