WEEKDAY()

E

Epinn

Bob,

Thank you for being patient and putting up with me. I am very unfamiliar with dates, just starting.
I did hear you - "......underlying value of a date is just the number of days since 1st Jan 1900...... when you key 21/4/2008 into cell A1, Excel recognises it as a date and converts it to an underlying value of 39559......" I registered the small pieces of info and I thought I understood. But when I tried to piece them together ...... Here's what has happened.

I had a blank cell and I thought I saw the format as "general." Then I keyed in a date like 21/4/2008 into the cell and I saw the exact same thing as I had keyed in. ***I was under the impression that "general" was still the format***. I didn't recheck the format at that point. When I did, I noticed that it was changed from "general" to "date." This is why I don't know that "general" format can display the actual no. of days. So, this is what I have missed and you can tell how green I am.
Dec 1899 was a saturday, which is day 7 to WEEKDAY. You get 7-Jan-00 because
it is formatted that way, the underlying value is 7.

When I read Biff's writeup, I found it very logical because I did agree that 1/1/1900 was a Sunday. But when I keyed in =WEEKDAY(0) ......

Ah, this is what I have missed from Biff's writeup and what I didn't do. Now, I am totally convinced. Bob, you are such a good teacher and thank you for clarifying. Now, I can explain =WEEKDAY(0) to other people in **absolute details**. ;)

Sorry, I skipped one step. I like programmers and/or accountants because they talk my language - exact and precise. Okay, I slipped occasionally. ;)

Is Norman Harker still around somewhere? Another MVP? After talking about 1900 for a few hours, I may have lost track of time. Okay, it is still 2006, I have just checked the clock on my computer. A while back, I had a post in another MS forum talking about "teleport" which was a feature I attempted to do using the MS software.

I'll worry about WORKDAY() after I have got some rest. What does ATP stand for? Just looking at your formula, I am relieved although I haven't digested it yet. Do you want to see the three-line formula a reputable web site suggested?

What do I do without you, Bob?

Epinn



Thank you all. This has been very educational. I have a few comments.
Please advise.

=A1 and format as General. As we said the underlying value of a date is just
the number of days since 1st Jan 1900, so it is already that number. You
just format it to see it.

Correct
omitted.

You may not want to, but Biff is right. 1st Jan 1900 was a Sunday, the 31st
Dec 1899 was a saturday, which is day 7 to WEEKDAY. You get 7-Jan-00 because
it is formatted that way, the underlying value is 7.

No, it yields 1. You just have it formatted as a date. A month number is not
a date, it is the ordinal value of the month within the year.

It does, as Excel "knows" that is not a date in its view of the world, but
you can fool it

=WEEKDAY(--"1900/01/01"-1)

returns 7.

Again as Biff, this is another nuance of Excel.

It would be nice if Norman Harker joined the discussion. He has made the
study of dates a speciality.
(Holidays is not a function.)

How about

=WORKDAY(DATE(YEAR(TODAY()),MONTH(TODAY())+1,0),-1)

or without the ATP function

=DATE(YEAR(A1),MONTH(A1)+1,0)-(MAX(0,WEEKDAY(DATE(YEAR(A1),MONTH(A1)+1,0),2)
-5))

Epinn

news:#[email protected]...
 
B

Bob Phillips

I know what you mean about the format. I have experienced that problem so
often that I added an edit field to one of my toolbars which shows the
format of the activecell. I cannot tell you how often I have found that
useful, the cell that I thought was a number turns out to be text.

Unfortunately, Norman seems to have been offline for quite some time. He is
an Excel MVP, and he specialises in Excel financial and date and time
functions (and giving extremely long and detailed answers <vbg>). If he were
around I am sure he wouldn't have written you an answer that would explain
things far better than I have.

ATP is the Analysis Toolpak, a Microsoft Excel addin that provides some
extra functions, of which the WORKDAY function is but one. and yes, I would
be interested in seeing your 3 line solution (and also knowing where it was
recommended <G>)

BTW, my first formula is wrong, it should be

=WORKDAY(DATE(YEAR(A1),MONTH(A1)+1,1),-1)


--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)

Bob,

Thank you for being patient and putting up with me. I am very unfamiliar
with dates, just starting.
I did hear you - "......underlying value of a date is just the number of
days since 1st Jan 1900...... when you key 21/4/2008 into cell A1, Excel
recognises it as a date and converts it to an underlying value of
39559......" I registered the small pieces of info and I thought I
understood. But when I tried to piece them together ...... Here's what has
happened.

I had a blank cell and I thought I saw the format as "general." Then I
keyed in a date like 21/4/2008 into the cell and I saw the exact same thing
as I had keyed in. ***I was under the impression that "general" was still
the format***. I didn't recheck the format at that point. When I did, I
noticed that it was changed from "general" to "date." This is why I don't
know that "general" format can display the actual no. of days. So, this is
what I have missed and you can tell how green I am.
31st
Dec 1899 was a saturday, which is day 7 to WEEKDAY. You get 7-Jan-00 because
it is formatted that way, the underlying value is 7.

When I read Biff's writeup, I found it very logical because I did agree that
1/1/1900 was a Sunday. But when I keyed in =WEEKDAY(0) ......

Ah, this is what I have missed from Biff's writeup and what I didn't do.
Now, I am totally convinced. Bob, you are such a good teacher and thank you
for clarifying. Now, I can explain =WEEKDAY(0) to other people in
**absolute details**. ;)

Sorry, I skipped one step. I like programmers and/or accountants because
they talk my language - exact and precise. Okay, I slipped occasionally.
;)

Is Norman Harker still around somewhere? Another MVP? After talking about
1900 for a few hours, I may have lost track of time. Okay, it is still
2006, I have just checked the clock on my computer. A while back, I had a
post in another MS forum talking about "teleport" which was a feature I
attempted to do using the MS software.

I'll worry about WORKDAY() after I have got some rest. What does ATP stand
for? Just looking at your formula, I am relieved although I haven't
digested it yet. Do you want to see the three-line formula a reputable web
site suggested?

What do I do without you, Bob?

Epinn
 
M

MartinW

Thanks RD,

That is a lot tidier than my Vlookup!

With the amount of computing power that is available these days
there is no real need to shorten processes (make it work no matter how
long winded and that's good enough is all that it really requires), however,
I still like to cut corners wherever I can. Old Habits...etc, etc.

Many Thanks
Martin
 
B

Bob Phillips

With the amount of computing power that is available these days
there is no real need to shorten processes (make it work no matter how
long winded and that's good enough is all that it really requires), however,
I still like to cut corners wherever I can. Old Habits...etc, etc.

I think there is. It is very easy to bring a spreadsheet to its knees with
poor design, coding, etc. Keep looking to cut those corners.
 
E

Epinn

I was in no way suggesting that Norman would explain things far better than you did. I was just wondering if he is someone of our time. Yes, good point, you are precise and concise which is very important as I can get lost in long strolls.

Everyone, I am going to start a new thread on WORKDAY(). If you are interested to join in, please move over.

Epinn

I know what you mean about the format. I have experienced that problem so
often that I added an edit field to one of my toolbars which shows the
format of the activecell. I cannot tell you how often I have found that
useful, the cell that I thought was a number turns out to be text.

Unfortunately, Norman seems to have been offline for quite some time. He is
an Excel MVP, and he specialises in Excel financial and date and time
functions (and giving extremely long and detailed answers <vbg>). If he were
around I am sure he wouldn't have written you an answer that would explain
things far better than I have.

ATP is the Analysis Toolpak, a Microsoft Excel addin that provides some
extra functions, of which the WORKDAY function is but one. and yes, I would
be interested in seeing your 3 line solution (and also knowing where it was
recommended <G>)

BTW, my first formula is wrong, it should be

=WORKDAY(DATE(YEAR(A1),MONTH(A1)+1,1),-1)


--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)

Bob,

Thank you for being patient and putting up with me. I am very unfamiliar
with dates, just starting.
I did hear you - "......underlying value of a date is just the number of
days since 1st Jan 1900...... when you key 21/4/2008 into cell A1, Excel
recognises it as a date and converts it to an underlying value of
39559......" I registered the small pieces of info and I thought I
understood. But when I tried to piece them together ...... Here's what has
happened.

I had a blank cell and I thought I saw the format as "general." Then I
keyed in a date like 21/4/2008 into the cell and I saw the exact same thing
as I had keyed in. ***I was under the impression that "general" was still
the format***. I didn't recheck the format at that point. When I did, I
noticed that it was changed from "general" to "date." This is why I don't
know that "general" format can display the actual no. of days. So, this is
what I have missed and you can tell how green I am.
31st
Dec 1899 was a saturday, which is day 7 to WEEKDAY. You get 7-Jan-00 because
it is formatted that way, the underlying value is 7.

When I read Biff's writeup, I found it very logical because I did agree that
1/1/1900 was a Sunday. But when I keyed in =WEEKDAY(0) ......

Ah, this is what I have missed from Biff's writeup and what I didn't do.
Now, I am totally convinced. Bob, you are such a good teacher and thank you
for clarifying. Now, I can explain =WEEKDAY(0) to other people in
**absolute details**. ;)

Sorry, I skipped one step. I like programmers and/or accountants because
they talk my language - exact and precise. Okay, I slipped occasionally.
;)

Is Norman Harker still around somewhere? Another MVP? After talking about
1900 for a few hours, I may have lost track of time. Okay, it is still
2006, I have just checked the clock on my computer. A while back, I had a
post in another MS forum talking about "teleport" which was a feature I
attempted to do using the MS software.

I'll worry about WORKDAY() after I have got some rest. What does ATP stand
for? Just looking at your formula, I am relieved although I haven't
digested it yet. Do you want to see the three-line formula a reputable web
site suggested?

What do I do without you, Bob?

Epinn
 
B

Bob Phillips

You might not of been, but I certainly was <vbg>

--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)

I was in no way suggesting that Norman would explain things far better than
you did. I was just wondering if he is someone of our time. Yes, good
point, you are precise and concise which is very important as I can get lost
in long strolls.

Everyone, I am going to start a new thread on WORKDAY(). If you are
interested to join in, please move over.

Epinn

I know what you mean about the format. I have experienced that problem so
often that I added an edit field to one of my toolbars which shows the
format of the activecell. I cannot tell you how often I have found that
useful, the cell that I thought was a number turns out to be text.

Unfortunately, Norman seems to have been offline for quite some time. He is
an Excel MVP, and he specialises in Excel financial and date and time
functions (and giving extremely long and detailed answers <vbg>). If he were
around I am sure he wouldn't have written you an answer that would explain
things far better than I have.

ATP is the Analysis Toolpak, a Microsoft Excel addin that provides some
extra functions, of which the WORKDAY function is but one. and yes, I would
be interested in seeing your 3 line solution (and also knowing where it was
recommended <G>)

BTW, my first formula is wrong, it should be

=WORKDAY(DATE(YEAR(A1),MONTH(A1)+1,1),-1)


--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)

Bob,

Thank you for being patient and putting up with me. I am very unfamiliar
with dates, just starting.
I did hear you - "......underlying value of a date is just the number of
days since 1st Jan 1900...... when you key 21/4/2008 into cell A1, Excel
recognises it as a date and converts it to an underlying value of
39559......" I registered the small pieces of info and I thought I
understood. But when I tried to piece them together ...... Here's what has
happened.

I had a blank cell and I thought I saw the format as "general." Then I
keyed in a date like 21/4/2008 into the cell and I saw the exact same thing
as I had keyed in. ***I was under the impression that "general" was still
the format***. I didn't recheck the format at that point. When I did, I
noticed that it was changed from "general" to "date." This is why I don't
know that "general" format can display the actual no. of days. So, this is
what I have missed and you can tell how green I am.
31st
Dec 1899 was a saturday, which is day 7 to WEEKDAY. You get 7-Jan-00 because
it is formatted that way, the underlying value is 7.

When I read Biff's writeup, I found it very logical because I did agree that
1/1/1900 was a Sunday. But when I keyed in =WEEKDAY(0) ......

Ah, this is what I have missed from Biff's writeup and what I didn't do.
Now, I am totally convinced. Bob, you are such a good teacher and thank you
for clarifying. Now, I can explain =WEEKDAY(0) to other people in
**absolute details**. ;)

Sorry, I skipped one step. I like programmers and/or accountants because
they talk my language - exact and precise. Okay, I slipped occasionally.
;)

Is Norman Harker still around somewhere? Another MVP? After talking about
1900 for a few hours, I may have lost track of time. Okay, it is still
2006, I have just checked the clock on my computer. A while back, I had a
post in another MS forum talking about "teleport" which was a feature I
attempted to do using the MS software.

I'll worry about WORKDAY() after I have got some rest. What does ATP stand
for? Just looking at your formula, I am relieved although I haven't
digested it yet. Do you want to see the three-line formula a reputable web
site suggested?

What do I do without you, Bob?

Epinn
 
R

Ragdyer

I must agree with Bob.

No matter how much computing power you have available, it is *very* easy to
bring the program to it's knees with *deficient* formulas/coding.

What can seem to operate efficiently in a 100 X 100 worksheet, can STOP an
entire machine if inserted in a 10,000 row database sheet.
And think what *will* happen with the XL07 *million* row program!

For example:

A Vlookup() formula, with an additional Vlookup() function call inserted for
error checking in a 40,000 X 150 database sheet can take 20 minutes to load
and/or recalc, where replacing it with an Index() and Match() combo can
reduce that to under 10 minutes.
Mind you, I'm *not* advocating XL's use as a database, just showing
comparisons.

AND ... *don't* try this at home ... BUT ...

=SUM($A$1:A1)

If used to produce a running total, works beautifully for several hundred
rows,
*BUT*
Just copying down 15,000 - 20,000 rows, can take more then 2 or 3 minutes.
AND - deleting that column of formulas can take in excess of 30 - 45
minutes.

SO, you should/must *always* be in the market for shorter, more efficient,
and/or smarter solutions.
 
M

MartinW

Hi Bob and RD

I guess I've got a bit of tunnelvision there!

You are right of course, however, where I work we really don't have
to be concerned about these sort of issues as all our spreadsheets are
very small. A 100 x 100 sheet would be fairly large to us.

Our sheets handle some very complex equations but any data analysis
and data storage is handled by a couple of database programs.

Basically we use Excel like a very powerful programmable
scientific calculator. Rather than looking for a smart solution that will
encompass all possibilities. It is quite often simpler to break a
calculation
down to small workable components with the use of helper cells
and put it all back together at the end.

Due to the fact that we are only using a very small part of the program's
capabilities we can take a lot of freedoms that would be unthinkable
in other disciplines (as you both quite rightly pointed out.)

The bottom line is it works for us very very well. I'm sure there are
plenty of other users who use Excel with the same cavalier attitude
as ourselves but collectively we would be a very small minority group.

Kind Regards
Martin
 
E

Epinn

Biff,

Thank you for taking the time to explain things to me, another "perfectionist." Unfortunately, I am learning how to run before I can walk steadily. Bob is right and I am having an episode of "information overload" at this time. I am sure that I can appreciate your analysis even better in the future and I look forward to more. By the way, "anal" is good, and I don't feel like I am the only one being detailed. All good programmers have a sense of perfection.

Cheers,

Epinn

Biff said:
When you enter it into a function, the function treats it as its argument,
and says that it is invalid as it expects a number (the true underlying
value). 21/4/2008 is not a number here, so it errors.

Actually, the formula does not "error" but calculates properly.

The argument: 2/14/2008 is the equivalent of:

2 divided by 14 divided by 2008

which equals: 0.0000711439954467843

Since WEEKDAY only works with integers Excel truncates the value to 0.

Weekday( 0 ) is actually 12/31/1899 which is a Saturday or weekday 7 when
the return_type used is 1 or omitted.

This is another Excel nuance. The date serial system doesn't start until day
1 which is 1/1/1900 yet you can calculate a date to be 1/0/1900. Excel
treats the 0th day of the month as the last day of the previous month.
That's how we end up with 7 as the result of the Weekday function.

Biff
 
E

Epinn

I better clarify for those who haven't read the other thread. "Anal" is a compliment by _ _ _ and I just carried it over. Hope using the word here hasn't offended anyone. ;)

Epinn

Biff,

Thank you for taking the time to explain things to me, another "perfectionist." Unfortunately, I am learning how to run before I can walk steadily. Bob is right and I am having an episode of "information overload" at this time. I am sure that I can appreciate your analysis even better in the future and I look forward to more. By the way, "anal" is good, and I don't feel like I am the only one being detailed. All good programmers have a sense of perfection.

Cheers,

Epinn

Biff said:
When you enter it into a function, the function treats it as its argument,
and says that it is invalid as it expects a number (the true underlying
value). 21/4/2008 is not a number here, so it errors.

Actually, the formula does not "error" but calculates properly.

The argument: 2/14/2008 is the equivalent of:

2 divided by 14 divided by 2008

which equals: 0.0000711439954467843

Since WEEKDAY only works with integers Excel truncates the value to 0.

Weekday( 0 ) is actually 12/31/1899 which is a Saturday or weekday 7 when
the return_type used is 1 or omitted.

This is another Excel nuance. The date serial system doesn't start until day
1 which is 1/1/1900 yet you can calculate a date to be 1/0/1900. Excel
treats the 0th day of the month as the last day of the previous month.
That's how we end up with 7 as the result of the Weekday function.

Biff
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top