473,410 Members | 1,946 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,410 software developers and data experts.

Return Number of Days In a month.

I am wanting to create my own calendar asp module.

Are there any functions in vbscript that return the number of days in a
particular month depending on what year it is ??
Jul 19 '05 #1
5 16551
You could do this:

iDays = Day(DateAdd("d", -1, DateAdd("m", 1, yourDate)))

If you don't have a value of "yourDate" and just have a month and a year,
do:

yourDate = yourYear & "-" & yourMonth & "-1"

What the code above is doing is taking your date, adding one month to it,
then subtracting one day.

Ray at work
"Adam Knight" <ad**********@optusnet.com.au> wrote in message
news:en**************@tk2msftngp13.phx.gbl...
I am wanting to create my own calendar asp module.

Are there any functions in vbscript that return the number of days in a
particular month depending on what year it is ??

Jul 19 '05 #2
Ray,

iDays = Day(DateAdd("d", -1, DateAdd("m", 1, yourDate)))

DateAdd("m",1, yourDate) -- so it goes to June 19 (assuming yourDate is
May19)
DateAdd("d",-1,theAbove) -- so it goes to June 18
Day(theAbove) -- 18

Am I missing something?
TomB
"Ray at <%=sLocation%> [MVP]" <myfirstname at lane34 dot com> wrote in
message news:eW**************@TK2MSFTNGP10.phx.gbl...
You could do this:

iDays = Day(DateAdd("d", -1, DateAdd("m", 1, yourDate)))

If you don't have a value of "yourDate" and just have a month and a year,
do:

yourDate = yourYear & "-" & yourMonth & "-1"

What the code above is doing is taking your date, adding one month to it,
then subtracting one day.

Ray at work
"Adam Knight" <ad**********@optusnet.com.au> wrote in message
news:en**************@tk2msftngp13.phx.gbl...
I am wanting to create my own calendar asp module.

Are there any functions in vbscript that return the number of days in a
particular month depending on what year it is ??


Jul 19 '05 #3
I was going with a "yourDate" as being the first of the month. If it's just
an arbitrary date, then you (or Adam?) could do:

myDate = "2004-05-19"
yourDate = Year(myDate) & "-" & Month(myDate) & "-1"

first. That will then do:
- go to beginning of month
- add one month
- subtract one day

Ray at work
"TomB" <sh*****@hotmailXXX.com> wrote in message
news:uI****************@TK2MSFTNGP11.phx.gbl...
Ray,

iDays = Day(DateAdd("d", -1, DateAdd("m", 1, yourDate)))

DateAdd("m",1, yourDate) -- so it goes to June 19 (assuming yourDate is
May19)
DateAdd("d",-1,theAbove) -- so it goes to June 18
Day(theAbove) -- 18

Am I missing something?
TomB
"Ray at <%=sLocation%> [MVP]" <myfirstname at lane34 dot com> wrote in
message news:eW**************@TK2MSFTNGP10.phx.gbl...
You could do this:

iDays = Day(DateAdd("d", -1, DateAdd("m", 1, yourDate)))

If you don't have a value of "yourDate" and just have a month and a year, do:

yourDate = yourYear & "-" & yourMonth & "-1"

What the code above is doing is taking your date, adding one month to it, then subtracting one day.

Ray at work
"Adam Knight" <ad**********@optusnet.com.au> wrote in message
news:en**************@tk2msftngp13.phx.gbl...
I am wanting to create my own calendar asp module.

Are there any functions in vbscript that return the number of days in a particular month depending on what year it is ??



Jul 19 '05 #4
Function GetDaysInMonth(dtmDate)
If IsDate(dtmDate) Then
dtmFirstOfMonth = DateSerial(Year(dtmDate),Month(dtmDate),1)
GetDaysInMonth = Day(DateAdd("d",-1,DateAdd("m",1,dtmFirstOfMonth)))
End If
End Function

'from dlbjr

'Unambit from meager knowledge of inane others,engender uncharted sagacity.
Jul 19 '05 #5
"dlbjr" <oo**@iforgot.com> wrote in message
news:eX**************@TK2MSFTNGP12.phx.gbl...
Function GetDaysInMonth(dtmDate)
If IsDate(dtmDate) Then
dtmFirstOfMonth = DateSerial(Year(dtmDate),Month(dtmDate),1)
GetDaysInMonth = Day(DateAdd("d",-1,DateAdd("m",1,dtmFirstOfMonth))) End If
End Function

'from dlbjr

'Unambit from meager knowledge of inane others,engender uncharted sagacity.


Day(DateSerial(Year(dtmDate),Month(dtmDate)+1,0))
Jul 19 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: josepe | last post by:
Hello, I need know the week nuber of the month. I know the function datepart() but returns the week number of the year a number between (1,53) I need a number between (1,4 o5). There is a...
7
by: developer | last post by:
I want to substract a number of month from a specific date. someone have a easy solution ? Thanks
1
by: Phil Endecott | last post by:
Dear Postgresql experts, According to the documentation for MOVE, it returns the number of rows that it has moved over. It seems to me that this is true for MOVE FORWARD n, but not for MOVE...
10
by: Bill | last post by:
Hello -- I'm parsing the output of the finger command, and was wondering something...If I'm given a month abbrievation (such as "Jan"), what's the best way to figure out the month number? I see...
6
by: kilter | last post by:
Anyone know of a routine that will return the number of rows and columns in a matrix?
1
by: Quazzie | last post by:
I have a form in Access with 2 date fields for completion. I want to query data from the 1st of the month (e.g. 01 April, 2007) to yesterday. For yesterday I use '=Date()-1', which works great but...
2
by: CindySue | last post by:
Hello--I've got a query that uses DatePart("m",) to select records for a particular month, and then a report based on that query. I'd like to be able to create a field in the report that says what...
5
by: girl23 | last post by:
I am using a function prototype to convert month number to month name. basically you ask the compiler to enter int from 1 to 12 and then convert it. printMonth ( number ); is the prototype and...
12
by: Be Borth | last post by:
I saw previous solutions to convert a month number (1) to a month name (January). I have a database with 200+ dates. In a query, I use the "Part" function DatePart("m",), to extract the month...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.