December 22, 2024
Share This:

I’ve been writing an application for work that requires me to display one weeks worth of data, starting on a Monday and ending on a Sunday. Below is the code that will find the first Monday and subsequent days dates.

This code would be useful for a calendar system, time-tracking application, project management etc.

<%
‘** Get Today’s Date
CurrentDate=FormatDateTime(Now,2)

blank

‘** Get Which day of the week it is (number)
FirstDayOfTheWeek=Weekday(CurrentDate, 2)

‘** Find how many days until Sunday are left
LastDayOfTheWeek=7-FirstDayOfTheWeek

The Pros And Cons Of Outsourcing PHP Developers
If you're looking to grow your business, one of the most logical places to do that is online. If you need to change your current website or build a new one you may wonder whether you should keep the development in-house or outsource it to save costs. In this article...

‘** Beginning of the week (Monday) Date
FindMonday=DateAdd(“d”,-FirstDayOfTheWeek, CurrentDate)+1

‘** End of the Week (Sunday) Date
FindSunday=DateAdd(“d”, LastDayOfTheWeek, CurrentDate)

Angular Vs React: Which One To Choose For Web Development?
Developers have got a number of options available these days when it comes to web development or creating an excellent web application. One can find an array of frontend JavaScript frameworks like Angular, React and, more. But with more options comes more confusion. Considering the advantages and disadvantages of different...

‘** Work out the dates for various days
Monday=FindMonday
Tuesday=DateAdd(“d”, FindMonday, 1)
Wednesday=DateAdd(“d”, FindMonday, 2)
Thursday=DateAdd(“d”, FindMonday, 3)
Friday=DateAdd(“d”, FindMonday, 4)
Saturday=DateAdd(“d”, FindMonday, 5)
Sunday=DateAdd(“d”, FindMonday, 6)

‘** Write Out the days and dates
Response.Write(“Mon – “&Monday&”<br>”)
Response.Write(“Tue – “&Tuesday&”<br>”)
Response.Write(“Wed – “&Wednesday&”<br>”)
Response.Write(“Thur – “&Thursday&”<br>”)
Response.Write(“Fri – “&Friday&”<br>”)
Response.Write(“Sat – “&Saturday&”<br>”)
Response.Write(“Sun – “&Sunday&”<br>”)
%>

blank

Please feel free to use the above code in any project – a mention would be nice too cheeky tongue

blank
About The Author
Katy is always trying to be more productive one day at a time! Whether it's analogue, digital, motivational or psychological who'll try any system that will help her get things done and get organised. As well as running FlippingHeck.com, she also loves making music and reviewing things.
  • Follow Katy Whitton on:
  • blank
  • blank
  • blank
  • blank
  • blank
  • blank
  • blank
  • blank
Please Note: This post may contain affiliate links. By clicking on these links you will not be charged any extra for purchasing goods and services from our preferred partners however flippingheck.com may receive financial compensation which contributes to the running of the site. For more information please read our Advertising & Affiliate Disclosure Policy
The short URL of the present article is: https://www.flippingheck.com/xmri

Leave a Reply

Your email address will not be published. Required fields are marked *