473,785 Members | 2,458 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Script to figure out if it's a weekend

Hey does anyone know of an easy script to use to figure out whether
the current date is a weekend or not, i currently have a script that
returns the current date and time. Also it would be great if it could
take into account holidays.
Jan 7 '08 #1
6 1654
ys******@gmail. com wrote:
Hey does anyone know of an easy script to use to figure out whether
the current date is a weekend or not, i currently have a script that
returns the current date and time. Also it would be great if it could
take into account holidays.
if (substr(date('D '),0,1) == 'S')
Jan 7 '08 #2
ys******@gmail. com wrote:
Hey does anyone know of an easy script to use to figure out whether
the current date is a weekend or not, i currently have a script that
returns the current date and time. Also it would be great if it could
take into account holidays.
|gregoriantojd( $month, $day, $year) % 7 = $day_of_the_wee k // Monday = 0|

--
*************** **************
Chuck Anderson • Boulder, CO
http://www.CycleTourist.com
Nothing he's got he really needs
Twenty first century schizoid man.
*************** *************** *****

Jan 7 '08 #3

"Paul Lautman" <pa**********@b tinternet.comwr ote in message
news:5u******** *****@mid.indiv idual.net...
ys******@gmail. com wrote:
>Hey does anyone know of an easy script to use to figure out whether
the current date is a weekend or not, i currently have a script that
returns the current date and time. Also it would be great if it could
take into account holidays.

if (substr(date('D '),0,1) == 'S')
L.U.D.I.C.R.O.U .S !!!

$dateInfo = getdate(date()) ;
$isWeekend = in_array($dateI nfo['wday], array(0, 6));

using substr is rediculous. 'domingo' is sunday and is ONE reason your
suggestion blows.
Jan 7 '08 #4

"Chuck Anderson" <we************ @seemy.sigwrote in message
news:XP******** *************** *******@comcast .com...
ys******@gmail. com wrote:
>Hey does anyone know of an easy script to use to figure out whether
the current date is a weekend or not, i currently have a script that
returns the current date and time. Also it would be great if it could
take into account holidays.

|gregoriantojd( $month, $day, $year) % 7 = $day_of_the_wee k // Monday = 0|
forgot about modulus!

$dateInfo = getdate(date()) ;
$isWeekend = $dateInfo['wday'] % 6 == 0;

that is faster than in_array. good catch.
Jan 7 '08 #5

"Steve" <no****@example .comwrote in message
news:wK******** *******@newsfe0 5.lga...
>
"Paul Lautman" <pa**********@b tinternet.comwr ote in message
news:5u******** *****@mid.indiv idual.net...
>ys******@gmail. com wrote:
>>Hey does anyone know of an easy script to use to figure out
whether
the current date is a weekend or not, i currently have a script
that
returns the current date and time. Also it would be great if it
could
take into account holidays.

if (substr(date('D '),0,1) == 'S')

L.U.D.I.C.R.O.U .S !!!

$dateInfo = getdate(date()) ;
$isWeekend = in_array($dateI nfo['wday], array(0, 6));

using substr is rediculous. 'domingo' is sunday and is ONE reason
your suggestion blows.

if( date('N') == 6 || date('N') == 7)

Wouldnt that do it?

R.
Jan 8 '08 #6

"Richard" <root@localhost wrote in message
news:47******** *************** @news.euronet.n l...
>
"Steve" <no****@example .comwrote in message
news:wK******** *******@newsfe0 5.lga...
>>
"Paul Lautman" <pa**********@b tinternet.comwr ote in message
news:5u******* ******@mid.indi vidual.net...
>>ys******@gmail. com wrote:
Hey does anyone know of an easy script to use to figure out whether
the current date is a weekend or not, i currently have a script that
returns the current date and time. Also it would be great if it could
take into account holidays.

if (substr(date('D '),0,1) == 'S')

L.U.D.I.C.R.O. U.S !!!

$dateInfo = getdate(date()) ;
$isWeekend = in_array($dateI nfo['wday], array(0, 6));

using substr is rediculous. 'domingo' is sunday and is ONE reason your
suggestion blows.


if( date('N') == 6 || date('N') == 7)

Wouldnt that do it?
more than one way to skin a cat. :)
Jan 8 '08 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
13462
by: AdityaK | last post by:
Is there a way to find Weekend date for a given date using a DB2 query? I see that there are scalar functions such as DAY, DAYOFMONTH, DAYOFWEEK,etc are available...but couldn't find one to get a weekend date for any given date. Any information is appreciated. Thanks, Aditya.
24
2176
by: Dave | last post by:
Maybe I'm missing something here, but I can't see the purpose of the 'finally' keyword. What is the difference between: try { doSomething() } catch { handleError(); }
3
1359
by: jonathan.beckett | last post by:
Hi all, I released a new version of the "PluggedOut Blog" script at the weekend - it's a PHP/MySQL solution for blogs, journals, diaries or any kind of calendar application. Homepage... http://www.pluggedout.com/index.php?pk=dev_blog Demonstration Blog...
4
2027
by: robinsand | last post by:
Header File: car.h #if !defined CAR_H #define CAR_H enum TCarType { ctEconomy = 1, ctCompact, ctStandard, ctFullSize, ctMiniVan, ctSUV }; class Car { public: Car();
2
1765
by: Joey Martin | last post by:
I have a sql database and ASP pages. How do I find out the DATES of THIS WEEKEND (fri-sun). If today is Tuesday, I want to show information posted for THIS WEEKEND. My table has a field called THEDATE which is what we need to search and in the format MM/DD/YYYY. Thanks!
3
1915
by: darnnnel | last post by:
Hey guys, i have this code: SELECT * FROM QueryCases WHERE Weekday(QueryCases.StartDate) In ('1','7') AND QueryCases.Completed = False ORDER BY QueryCases.StartDate; the WHERE Weekday(QueryCases.StartDate) In ('1','7') returns any weekend records, how do i set criteria to only show weekend records for this coming weekend. Thanks in advance
3
6299
by: sigkill9 | last post by:
I've been working on this script all weekend and am almost done with it accept for one last detail; implementing a "process another number?" prompt after a user input is processed. The script works like this: First, the user enters a number to test (to find the two prime numbers that make up that number). Next the program finds the numbers, outputs them, then quits. What I want to do is create a prompt after the number has been processed...
30
2855
by: Paul W Smith | last post by:
I have written a hit counter, which I believe counts the times my page is hit by a user for each unique session by the user. The relevant part of my code is below: If IsEmpty(Session("TotalCount")) Then ' Increment or reset the count If Weekday(Date(),vbSunday) = 1 And dtDate <Date then
7
3224
by: Mike | last post by:
I have a routine that's calculating business days but its not counting the weekend days that are between the start date and end date. If my start date is 9/26/08 and my end date is 10/01/08, I should see 4 business days and 2 weekend days. How can I get that result? I'm getting 4 business days but its not counting the weekend days?
0
9645
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9480
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10147
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10091
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9950
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8972
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7499
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5511
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4050
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.