473,890 Members | 1,192 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 16778
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**********@o ptusnet.com.au> wrote in message
news:en******** ******@tk2msftn gp13.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******** ******@TK2MSFTN GP10.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**********@o ptusnet.com.au> wrote in message
news:en******** ******@tk2msftn gp13.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*****@hotmai lXXX.com> wrote in message
news:uI******** ********@TK2MSF TNGP11.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******** ******@TK2MSFTN GP10.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**********@o ptusnet.com.au> wrote in message
news:en******** ******@tk2msftn gp13.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 ,dtmFirstOfMont h)))
End If
End Function

'from dlbjr

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

'from dlbjr

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


Day(DateSerial( Year(dtmDate),M onth(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
2530
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 function or method that i can use to do it? Thanks a lot.
7
16247
by: developer | last post by:
I want to substract a number of month from a specific date. someone have a easy solution ? Thanks
1
2014
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 RELATIVE n or MOVE ABSOLUTE n when it always returns 1: db=> declare c scroll cursor for select * from p; DECLARE CURSOR db=> move absolute -1 in c;
10
7345
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 that there's something called "month_abbr" in the calendar module. However, when I try to do calendar.month_abbr.index("Jan"), I get "_localized_month instance has no attribute 'index'." So it seems that month_abbr isn't a regular list. I'm...
6
3985
by: kilter | last post by:
Anyone know of a routine that will return the number of rows and columns in a matrix?
1
10707
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 can't figure out what to use for the other date field. Will I need to write a function to return this date? Will the function use 'Date' to retrieve the information or will it use the date field box name? Hope you can help with this, it is...
2
26577
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 month they are for. I can get the month number by using =DatePart("m",) in a text box, but I can't find a way to convert it to the month name. I've experimented with a couple of things I found in the forum, but I'm not talented enough to get them to...
5
14465
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 using switch this is what i did case 'm': printf( "What month? Enter a number between 1 and 12: " ); scanf( "%d%c", &number, &tmp ); printMonth( number ); break;
12
23233
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 (number) and all month extracts worked correctly (they returned the correct numerical month). However, when I attempted adding a field in the query to format that extracted month to a month name, it only returned January and December - for all 200+...
0
9978
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9820
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
11227
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10922
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9630
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
8016
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
7169
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
6041
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
3276
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.