|
 |
access thread: Days and Month in Date
Message #1 by "Adeyemi Ajao" <adeyemiajao@h...> on Fri, 28 Dec 2001 22:11:04 +0000
|
|
Hello dears,
Could anybody assist me on any available functions to achieve the following:
1. Getting the number of days in any given month within a date
2. Getting the Month portion of a date in text form (not number)
Cheers.
Adeyemi
_________________________________________________________________
Chat with friends online, try MSN Messenger: http://messenger.msn.com
Message #2 by "Gerald, Rand" <RGerald@u...> on Fri, 28 Dec 2001 16:58:01 -0600
|
|
Adeyemi,
Here is some code:
' This function calculates the number of days in a month.
' Input: dIn - Any date in the desired month.
' Output: DaysInMonth - The number of days in the month.
Public Function DaysInMonth(dIn As Date) As Integer
Dim NextMonth As Date
Dim EndOfMonth As Date
NextMonth = DateAdd("m", 1, dIn)
EndOfMonth = NextMonth - DatePart("d", NextMonth)
DaysInMonth = DatePart("d", EndOfMonth)
End Function
For more information check the following reference in the Microsoft
Knowledge base:
ACC2000: How to Find the Number of Days in a Month (Q210448)
You only need to search for the "Q" number. E.g. Q210448
Rand
Ps: I had originally designed a different routine for doing the same thing,
but I found the Microsoft version to be more elegant (less code)!
The month portion of the date is available from the Format function.
Format(#12/28/2001#, "mmmm") for "December" or
Format(#12/28/2001#, "mmm") for "Dec"
The Format function will also take variables or field names for the date.
Rand
-----Original Message-----
From: Adeyemi Ajao [mailto:adeyemiajao@h...]
Sent: Friday, December 28, 2001 4:11 PM
To: Access
Subject: [access] Days and Month in Date
Hello dears,
Could anybody assist me on any available functions to achieve the following:
1. Getting the number of days in any given month within a date
2. Getting the Month portion of a date in text form (not number)
Cheers.
Adeyemi
_________________________________________________________________
Chat with friends online, try MSN Messenger: http://messenger.msn.com
Message #3 by "David Chapman" <luckychap@b...> on Sun, 30 Dec 2001 09:13:10 +1030
|
|
mthlen = dateserial(year(thedate),month(thedate)+1),0)
There are many other ways of doing it.
StrMonthName = format(thedate,"mmm")
There may not be a need to store that string in your data.
David
----- Original Message -----
From: "Adeyemi Ajao" <adeyemiajao@h...>
To: "Access" <access@p...>
Sent: Saturday, December 29, 2001 8:41 AM
Subject: [access] Days and Month in Date
>
>
> Hello dears,
> Could anybody assist me on any available functions to achieve the
following:
>
> 1. Getting the number of days in any given month within a date
>
> 2. Getting the Month portion of a date in text form (not number)
>
> Cheers.
>
> Adeyemi
>
> _________________________________________________________________
> Chat with friends online, try MSN Messenger: http://messenger.msn.com
>
>
|
|
 |