logo
down
shadow

Check if todays is first weekday of month?


Check if todays is first weekday of month?

By : user2949391
Date : November 17 2020, 01:00 AM
I wish this helpful for you I wish to check if the current date is the first weekday of the month, I wondered if there is an easier way to do this? Currently, I use the following coding to determine the first weekday and then match it to another textbox which has todays date. , you can try this function
code :
Public Function FirstMonday(year As Integer, month As Integer) As DateTime
    Dim firstDay As New DateTime(year, month, 1)
    If firstDay.DayOfWeek = DayOfWeek.Monday Then
        Return firstDay
    Else
        Dim days = DayOfWeek.Monday - firstDay.DayOfWeek ' in case the first day was less than monday
        If firstDay.DayOfWeek > DayOfWeek.Monday Then days = 7 - firstDay.DayOfWeek + DayOfWeek.Monday ' in case if the first day was > monday              
        Return firstDay.AddDays(days)
    End If
End Function
dim monday=FirstMonday(2014,6) ' for example
Public Function FirstDayOfWeek(year As Integer, month As Integer, Day As DayOfWeek) As DateTime
    Dim firstDay As New DateTime(year, month, 1)
    If firstDay.DayOfWeek = Day Then
        Return firstDay
    Else
        Dim days = Day - firstDay.DayOfWeek ' in case the first day was less than DayOfWeek
        If firstDay.DayOfWeek > Day Then days = 7 - firstDay.DayOfWeek + Day ' in case if the first day was > DayOfWeek             
        Return firstDay.AddDays(days)
    End If
End Function
First Monday in [Jan 2014] is 06 Jan 2014
First Monday in [Feb 2014] is 03 Feb 2014
First Monday in [Mar 2014] is 03 Mar 2014
First Monday in [Apr 2014] is 07 Apr 2014
First Monday in [May 2014] is 05 May 2014
First Monday in [Jun 2014] is 02 Jun 2014
First Monday in [Jul 2014] is 07 Jul 2014
First Monday in [Aug 2014] is 04 Aug 2014
First Monday in [Sep 2014] is 01 Sep 2014
First Monday in [Oct 2014] is 06 Oct 2014
First Monday in [Nov 2014] is 03 Nov 2014
First Monday in [Dec 2014] is 01 Dec 2014


Share : facebook icon twitter icon
To check weekday of a month

To check weekday of a month


By : user848499
Date : March 29 2020, 07:55 AM
fixed the issue. Will look into that further You can use the DayOfWeek property.
Using momentjs, how can I find which weekday number a specific day is in a month, and how many of a weekday are in a giv

Using momentjs, how can I find which weekday number a specific day is in a month, and how many of a weekday are in a giv


By : yuen
Date : March 29 2020, 07:55 AM
it fixes the issue The answer provided by dave is very good but needs a small modification:
code :
Math.floor(DAYS_IN_MONTH / 7) + ((DAYS_IN_MONTH % 7 >= ((X - 1) % 7) + 1) ? 1 : 0)
Math.floor(28 / 7) + ((28 % 7 >= 7 % 7) ? 1 : 0) =
4 + ((0 >= 0) ? 1 : 0) =
4 + (true ? 1 : 0) =
4 + 1 =
5
Math.floor(28 / 7) + ((28 % 7 >= ((7 - 1) % 7) + 1) ? 1 : 0) =
4 + ((0 >= (6 % 7) + 1) ? 1 : 0) =
4 + ((0 >= 6 + 1) ? 1 : 0) =
4 + ((0 >= 7) ? 1 : 0) =
4 + (false ? 1 : 0) =
4 + 0 =
4
Find weekday of a date given the month start weekday

Find weekday of a date given the month start weekday


By : user2549587
Date : March 29 2020, 07:55 AM
wish helps you It is hard to use modular arithmetic if you don't start counting from zero.
So let's define some new variables:
Python: Check if today is first weekday of the month

Python: Check if today is first weekday of the month


By : Matt
Date : March 29 2020, 07:55 AM
should help you out I wondered how to check if the current day is the first weekday of the month in Python and could not find any solution on the web. So I thought I post mine, in case anyone needs to solve this too.
code :
import datetime

weekday = datetime.datetime.today().weekday()
day = datetime.datetime.today().day
date_str = datetime.datetime.today().strftime("%A, %d-%m-%Y")

if (weekday == 0 and day in (1, 2, 3)) or (weekday in (1, 2, 3, 4) and day == 1):
    print("Today {0} is the first weekday of the month.".format(date_str))
else:
    print("Today {0} is not the first weekday of the month.".format(date_str))
Check N-th repetition of a weekday in a given month

Check N-th repetition of a weekday in a given month


By : user3353686
Date : March 29 2020, 07:55 AM
seems to work fine This is actually very straightforward and requires simply knowing the day of the month. If the date is the 12th of October and it's a Saturday, then it must be the second Saturday because to be the third or more Saturday, there would have to be 14 or more days before it in the month, and to be the first Saturday there would have to be fewer than 7 days before it in the month.
The calculation is as simple as (day_of_month - 1) // 7 + 1 to work out how many multiples of 7 days occur before day_of_month, and then add 1. The // operator is integer division, rounding down.
Related Posts Related Posts :
  • how to refresh my datagridview after I add new data
  • How to get Motherboard name in VB.net?
  • Loop Through LINQ Results
  • How do I remove this GoTo?
  • Display image in DataGridView not working properly
  • How can limit how many times an operator shows up in my maths quiz in vb?
  • Expression Lambda to order fields with null value
  • DevExpress Add items to ComboBox at run time
  • GetManifestResourceStream in module
  • Save and open vbs script programmatically
  • Option Strict On, set Focus of unknown object type
  • Google API No application is associated with the specified file for this operation
  • Converting items in listview too string. VB
  • Mouse position at end of textbox on Mouse Click event
  • Run or Embed VB.NET console application within a VB.NET or C# forms application
  • Getting error while running the query
  • DevExpress GridView FocusedRowHandle Does not update on right click
  • Inserting combo box values?
  • Local RDLC report using spatial data
  • vb.net database query and checkbox , proper way to do?
  • Why error ???? Syntax error in INSERT INTO statement
  • string.IsNullOrEmpty vs string = '' in Visual Basic
  • Execute a subroutine before exiting the application
  • comparing two dates at midnight in vb never match
  • DataSource No Longer Fills Data Calls VB 2010
  • VB.NET - LINQ - dbContext - Where - Letter is not declared error. Trying to update single record
  • What is the equivalent of FirstSibling in .NET XMLNode?
  • Get value of one columns in DataGridView with multi select vb.net
  • shadow
    Privacy Policy - Terms - Contact Us © ourworld-yourmove.org