LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11
Default Excel dates seem to confuse me ...

OK, here goes,

I have to create a function in Excel that shows a date string of the
format "TLyyyymmww" based on the following parameters :
a) "ww" is the week number of the week of that date, all weeks begin on
a Sunday
b) "mm" is the month number of the week described in a)
c) "yyy" is the year number of the week described in a)

What I do not understand is why must I trap the occurance of
"30-Dec-2007". If I do not then then answer will be "TL2007.12.53"
instead of "TL2008.01.01". I know this date does not work correctly but
wondered if anyone knew WHY it must be trapped. and if there anr any
other possible dated that will yield the same error

'''''''''''''''''''''''''''''''''''''''''''''''''' ''''''''
'''''''''''''''''''''''''''''''''''''''''''''''''' ''''''''
Function TILPeriod(xDate As Date) As String
Dim d As Date, w As Integer, y As Integer, m As Integer

d = Int((xDate - vbSunday) / 7) * 7 + vbSunday
w = Format(xDate, "ww", vbSunday, vbFirstFourDays)
y = Year(d)
m = Month(d)

' in case this December week should be
'moved to January next year
If (w = 1) And (m = 12) Then
m = 1
y = y + 1
'WHY !!!!!!!!!!!!!!!!!
ElseIf (d = #12/30/2007#) Then
w = 1
m = 1
y = y + 1
End If

TILPeriod = "TL" & y & "." & Format(m, "00") & "." & Format(w, "00")
End Function
'''''''''''''''''''''''''''''''''''''''''''''''''' ''''''''
'''''''''''''''''''''''''''''''''''''''''''''''''' ''''''''


Clear as mud I suppose, but I do not know if this is a coding or
mathematical problem, and any help yould be great


Sean
"Just press the off switch, and go to sleep!"

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
 
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
Why does this confuse me?? -- ? on Offset function Awrex Excel Worksheet Functions 1 May 6th 10 01:14 AM
confuse on vlookup, index match vcff Excel Discussion (Misc queries) 1 December 1st 06 01:19 AM
confuse on vlookup, index match [email protected] Excel Discussion (Misc queries) 0 November 30th 06 05:52 AM
confuse on vlookup, index match vcff Excel Discussion (Misc queries) 0 November 30th 06 12:11 AM
confuse on vlookup, index match [email protected] Excel Discussion (Misc queries) 0 November 29th 06 08:59 AM


All times are GMT +1. The time now is 08:56 AM.

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

About Us

"It's about Microsoft Excel"