[AccessD] Date calculation code

Joe Rojas JRojas at tnco-inc.com
Fri Feb 28 16:01:00 CST 2003


Thanks Josh and Drew!

I decided to go with Josh's code. I just modified it a little and came up
with this.


Public Function fDayofWeek(intWeekNumber As Integer, intDayNumber As
Integer, dtTemp As Date) As Date

'============================
'intWeekNumber: 1 = first
'               2 = second
'               3 = third
'               4 = fourth
'               5 = last
'============================

Dim dtTemp2 As Date

'set dtTemp2 to the first day of the month of dtTemp
dtTemp2 = DateSerial(Year(dtTemp), Month(dtTemp), 1)

'Find the first Day that equals intDayNumber
While (DatePart("w", dtTemp2) <> intDayNumber)
    dtTemp2 = DateAdd("d", 1, dtTemp2)
Wend

dtTemp2 = DateAdd("d", ((intWeekNumber - 1) * 7), dtTemp2)

If (DatePart("m", dtTemp2) = DatePart("m", dtTemp)) Then
    fDayofWeek = dtTemp2
Else
    If (intWeekNumber = 5) Then '5 = "Last"
        fDayofWeek = DateAdd("d", -7, dtTemp2)
    Else
        MsgBox "Internal error: fDatofWeek()", vbCritical, "Error"
        fDayofWeek = 0
    End If
End If

End Function



Thanks again!
Joe Rojas

-----Original Message-----
From: Drew Wutka [mailto:DWUTKA at marlow.com]
Sent: Friday, February 28, 2003 10:10 AM
To: 'accessd at databaseadvisors.com '
Subject: RE: [AccessD] Date calculation code

Did my old site have a version of the MiniCalendar with that feature?

Drew

-----Original Message-----
From: Jim Lawrence (AccessD)
To: accessd at databaseadvisors.com
Sent: 2/28/03 3:54 AM
Subject: RE: [AccessD] Date calculation code

Excellent...

Jim

-----Original Message-----
From: accessd-admin at databaseadvisors.com
[mailto:accessd-admin at databaseadvisors.com]On Behalf Of Drew Wutka
Sent: Thursday, February 27, 2003 9:52 PM
To: 'accessd at databaseadvisors.com'
Subject: RE: [AccessD] Date calculation code


I have a function that does that in my MiniCalendar.  I don't know if my
site (www.wolfwares.com) has the latest version.  If you don't see a
'day of
week' example, let me know.  (My website that is 'live' is actually a
few
years old....I'm jumping through hoops with my DSL provider to get my
current site live again!....which by the way (for those of you who are
waiting for the archives to be online again....I have been 'promised' to
have static IP Addresses within the week, so I should have the archives
up
and running by next weekend (keeping fingers crossed)....with the
indexed
messages too (I've decreased the search time immensely...searches
through
either/both the subject and message body field now kick out in a
fraction of
a second....)

Drew

-----Original Message-----
From: Joe Rojas [mailto:JRojas at tnco-inc.com]
Sent: Thursday, February 27, 2003 1:15 PM
To: 'accessd at databaseadvisors.com'
Subject: [AccessD] Date calculation code


Hi All,

        Does anyone have code that they can share that performs date
calculations that return dates for inquiries like "last Thursday of a
month", "second Monday of a month", "fourth Tuesday of a month", etc...

Thanks!

Joe Rojas




This electronic transmission is strictly confidential to TNCO, Inc. and
intended solely for the addressee. It may contain information which is
covered by legal, professional, or other privileges. If you are not the
intended addressee, or someone authorized by the intended addressee to
receive transmissions on behalf of the addressee, you must not retain,
disclose in any form, copy, or take any action in reliance on this
transmission. If you have received this transmission in error, please
notify
the sender as soon as possible and destroy this message. While TNCO,
Inc.
uses virus protection, the recipient should check this email and any
attachments for the presence of viruses. TNCO, Inc. accepts no liability
for
any damage caused by any virus transmitted by this email.
_______________________________________________
AccessD mailing list
AccessD at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/accessd
Website: http://www.databaseadvisors.com
_______________________________________________
AccessD mailing list
AccessD at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/accessd
Website: http://www.databaseadvisors.com

_______________________________________________
AccessD mailing list
AccessD at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/accessd
Website: http://www.databaseadvisors.com
_______________________________________________
AccessD mailing list
AccessD at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/accessd
Website: http://www.databaseadvisors.com



This electronic transmission is strictly confidential to TNCO, Inc. and
intended solely for the addressee. It may contain information which is
covered by legal, professional, or other privileges. If you are not the
intended addressee, or someone authorized by the intended addressee to
receive transmissions on behalf of the addressee, you must not retain,
disclose in any form, copy, or take any action in reliance on this
transmission. If you have received this transmission in error, please notify
the sender as soon as possible and destroy this message. While TNCO, Inc.
uses virus protection, the recipient should check this email and any
attachments for the presence of viruses. TNCO, Inc. accepts no liability for
any damage caused by any virus transmitted by this email.



More information about the AccessD mailing list