Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,494
Default datepart question

thanks, rick. i mistyped and the 6 should have been 5.

--


Gary

"Rick Rothstein" wrote in message
...
Contrary to what the help file says, I don't think the 4th argument has any
bearing on the return value from the DatePart function when the first argument
is "w" (try all the possible arguments for the 4th argument... for a given
date and start of week, you will always get the same value). Now, as to what
the function is returning... I don't think it is doing what you seem to think
it is. With the "w" argument, it is giving you the weekday number of the date
you provide with the count starting as indicated by the 3rd argument. So, for
this...

DatePart("w", DateSerial(2009, 1, 1), vbMonday, vbFirstFullWeek)

it returns 4 because the January 1, 2009 occurs on a Thursday which is the 4th
day of the week when the week starts on Monday (Monday is 1, Tuesday is 2,
Wednesday is 3 and Thursday is 4). As for this...

DatePart("w", DateSerial(2010, 1, 1), vbMonday, vbFirstFullWeek)

you said it returns 6, but actually, it returns 5 and that is because January
1, 2010 occurs on Friday and Friday is the 5th day of the week when the week
starts on a Monday.

--
Rick (MVP - Excel)


"Gary Keramidas" <GKeramidasAtMsn.com wrote in message
...
can someone explain what i am seeing?

this expression returns 4
DatePart("w", DateSerial(2009, 1, 1), vbMonday, vbFirstFullWeek)

the 1st is on thursday and the first monday is the 5th, which is 4 days
later.

but this expression returns 6, which doesn't make sense to me. i would think
it would return 3
DatePart("w", DateSerial(2010, 1, 1), vbMonday, vbFirstFullWeek)

so, i guess i'm missing something.


--


Gary





Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
datePart Function Carlee Excel Programming 2 April 3rd 07 01:08 AM
DatePart Function in VBA ExcelMonkey Excel Programming 3 March 21st 06 12:49 PM
Datepart problem Ron Dean Excel Programming 7 January 6th 06 03:04 PM
Good morning or good evening depending upon your location. I want to ask you the most important question of your life. Your joy or sorrow for all eternity depends upon your answer. The question is: Are you saved? It is not a question of how good you [email protected] Excel Programming 23 April 23rd 05 09:26 PM
Good morning or good evening depending upon your location. I want to ask you the most important question of your life. Your joy or sorrow for all eternity depends upon your answer. The question is: Are you saved? It is not a question of how good you [email protected] Excel Programming 0 April 22nd 05 03:30 PM


All times are GMT +1. The time now is 11:50 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"