Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Check Day & Month of Current Date

Tags:

date

vb.net

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?

like image 929
John White Avatar asked Dec 21 '12 16:12

John White


People also ask

What is the date today 2022?

The date today is Thursday, October 13, 2022.

What day of the year is it out of 365 days 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.

Which is the day of the week?

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.

How do you count days?

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.


4 Answers

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
like image 126
slolife Avatar answered Oct 15 '22 11:10

slolife


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.

like image 30
Tim Schmelter Avatar answered Oct 15 '22 11:10

Tim Schmelter


Date.Now.Month and Date.Now.Day. Those are properties on the Date type.

like image 21
Jason Tyler Avatar answered Oct 15 '22 11:10

Jason Tyler


Dim today = Date.Now.Date
If today.Day = 9 AndAlso today.Month = 10 Then ...
like image 38
Mark Hurd Avatar answered Oct 15 '22 11:10

Mark Hurd