date create - opposite of datepart?

# Thread: date create - opposite of datepart?

1. Senior Member
Join Date
Dec 1969
Posts
380

## date create - opposite of datepart?

Hello,<BR><BR>is there a way to do the opposite of what datepart does?<BR><BR>like knowing the date/day week ?? in year ???? starts with?

2. Senior Member
Join Date
Dec 1969
Posts
16,931

## RE: date create - opposite of datepart?

Sorry, what are you after?<BR><BR>Explain. Forget datepart, just what you&#039;re AFTER.<BR><BR>Craig.

3. Senior Member
Join Date
Dec 1969
Posts
380

## RE: date create - opposite of datepart?

if you want to know the date of lets say<BR><BR>day 3 in week 12 of year 2004

4. Senior Member
Join Date
Dec 1969
Posts
16,931

## RE: date create - opposite of datepart?

No, no way to do exactly that. You&#039;d have to build it up yourself.<BR><BR>Craig.

5. Senior Member
Join Date
Dec 1969
Posts
96,118

## *EASY* to do....

...but the problem is defining what is the start of a week.<BR><BR>Is Jan 1 the first day of the first week? So that 7 days later, Jan 8, is the first day of the second week?<BR><BR>Or is the week that *CONTAINS* Jan 1 the first week, starting on Sunday (or some other day???) no matter what day Jan 1 is?<BR><BR>Or what???<BR><BR>Most of the time, in the USA, we go with that 2nd definition. So the first thing you have to do is figure out what day is the start of the first week of the year...even if it is in the prior year!<BR><BR>After that it&#039;s easy.<BR><BR>&#060;%<BR>Function BuildDate( dayNum, weekNum, yr )<BR> Dim jan1<BR> jan1 = DateSerial( yr, 1, 1 )<BR> Dim startFirstWeek = jan1 - Weekday(jan1) + 1<BR> BuildDate = CDate( startFirstWeek + 7 * ( weekNum-1 ) + ( dayNum-1 ) )<BR>End Function<BR>%&#062;<BR><BR>The CDATE probably isn&#039;t needed, but a little paranoia can&#039;t hurt.<BR><BR><BR>

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•