All source code in ASP/ VbScript Ask a ASP/ VbScript Pro Discussion Forum Categories All jobs in ASP/ VbScript
Quick Search for:  in language:    
Last,Month,FunctionPass,function,will,return,
   Code/Articles » |  Newest/Best » |  Community » |  Jobs » |  Other » |  Goto » | 
CategoriesSearch Newest CodeCoding ContestCode of the DayAsk A ProJobsUpload
ASP/ VbScript Stats

 Code: 281,486. lines
 Jobs: 101. postings

 How to support the site

 
Sponsored by:

 
You are in:
 
Login

NEW! LEARNING CENTER
Special educational offers, white papers, webcasts, podcasts

  NEW! Download Rational Performance Tester V8 (download now)
  NEW! Download Rational Functional Tester V8 (download now)
  NEW! Download Rational Service Tester for SOA Quality V8 (download now)
  NEW! Teleconference: Quality In Action - Using Rational Quality Manager with Functional, Performance and Web Service Testing Products (download now)
  NEW! Introducing IBM Rational AppScan Developer Edition – easing security testing by non-security professionals (download now)

 

 


Latest postings for ASP/ VbScript.
Click here to see a screenshot of this code!Mess Officer Management System (Sistem Pengurusan Mess Pegawai)
By Mohd Fauzi on 11/23

(Screen Shot)

Click here to put this ticker on your site!


Add this ticker to your desktop!


Daily Code Email
To join the 'Code of the Day' Mailing List click here!



 
 
   

Get Last Day of Month Function

Print
Email
 
VB icon
Submitted on: 11/10/2002 8:27:11 AM
By: Johannf  
Level: Beginner
User Rating: By 2 Users
Compatibility:ASP (Active Server Pages)

Users have accessed this code 12836 times.
 
(About the author)
 
     Get Last Day of Month Function Pass the function any day and it will return the last day of the month of that date.
 
code:
Can't Copy and Paste this?
Click here for a copy-and-paste friendly version of this code!
 
Terms of Agreement:   
By using this code, you agree to the following terms...   
1) You may use this code in your own programs (and may compile it into a program and distribute it in compiled format for languages that allow it) freely and with no charge.   
2) You MAY NOT redistribute this code (for example to a web site) without written permission from the original author. Failure to do so is a violation of copyright laws.   
3) You may link to this code from another website, but ONLY if it is not wrapped in a frame. 
4) You will abide by any additional copyright restrictions which the author may have placed in the code or code's description.

    '**************************************
    ' Name: Get Last Day of Month Function
    ' Description:Get Last Day of Month Func
    '     tion
    Pass the function any day and it will return the last day of the month of that date.
    ' By: Johannf
    '
    ' Inputs:Date
    '
    ' Returns:Integer
    '
    'This code is copyrighted and has    ' limited warranties.Please see http://w
    '     ww.Planet-Source-Code.com/vb/scripts/Sho
    '     wCode.asp?txtCodeId=7986&lngWId=4    'for details.    '**************************************
    
    function LastDayOfMonth(DateIn)
    	Dim TempDate
    	TempDate = Year(dateIn) & "-" & Month(DateIn) & "-"
    	if IsDate(TempDate & "28") Then LastDayOfMonth = 28
    	if IsDate(TempDate & "29") Then LastDayOfMonth = 29
    	if IsDate(TempDate & "30") Then LastDayOfMonth = 30
    	if IsDate(TempDate & "31") Then LastDayOfMonth = 31
    End function

 
 Report Bad Submission
Use this form to notify us if this entry should be deleted (i.e contains no code, is a virus, etc.).
This submission should be removed because:
 
Your Vote!

What do you think of this code(in the Beginner category)?
(The code with your highest vote will win this month's coding contest!)
Excellent  Good  Average  Below Average  Poor See Voting Log
 
Other User Comments
11/12/2002 10:48:13 PM

Good~!!!
(If this comment was disrespectful, please report it.)

 
11/15/2002 7:43:27 AMAndrew Steitz

5 globes. Why? Simplicity, baby. I might add a check to see if the date passed in is valid before extracting the year and month, though. Always validate data before manipulating.
(If this comment was disrespectful, please report it.)

 
11/17/2002 11:52:48 PMShannon Harmon

Nice routine, you can also do it this way. If this doesn't get chopped to death as a comment. <% Response.Write LastDayOfMonth(Now()) Function LastDayOfMonth(ByVal dteDate) Dim dteRet If IsDate(dteDate) Then dteRet = DateValue(Month(dteDate) & "/1/" & Year(dteDate)) dteRet = DateAdd("m", 1, dteRet) - 1 LastDayOfMonth = Day(dteRet) Else LastDayOfMonth = NULL End If End Function %>
(If this comment was disrespectful, please report it.)

 
11/25/2002 9:46:23 AMRiverside

Or Like this:

Function ReturnMonthEnd(strDate)
mm = Month(strDate) + 1
If mm > 12 Then mm = 1
ReturnMonthEnd = DateValue(mm
(If this comment was disrespectful, please report it.)

 
3/12/2003 5:53:27 AM

wasting time to write the code...

how bout my code:

msgbox day(dateadd("d",-1, monthname(month(date)+1)&"/1/"&year(date)))


from the code above, no matter what your PC setting for date format wether dd/mm/yyyy or mm/dd/yyyy. the code will works...

wassalam
(If this comment was disrespectful, please report it.)

 
5/1/2003 11:36:58 AM

Another solution:
LastDay = DatePart("d",DateSerial(Year(dteDate),Month(dteDate)+1,0))
(If this comment was disrespectful, please report it.)

 
11/11/2003 11:08:38 PM

This is an awesome function. Not only does it work but it is easy on the eyes and brain.
(If this comment was disrespectful, please report it.)

 
11/13/2003 5:10:21 AM

One error is there in your coding,
You should put these coding lines in reverse order.
That's is start from 31 instead of 28 and go towards 28.
Got it.
(If this comment was disrespectful, please report it.)

 
12/15/2006 7:20:11 AMMuhammad Imran

Good Work
(If this comment was disrespectful, please report it.)

 
Add Your Feedback!
Note:Not only will your feedback be posted, but an email will be sent to the code's author from the email account you registered on the site, so you can correspond directly.

NOTICE: The author of this code has been kind enough to share it with you.  If you have a criticism, please state it politely or it will be deleted.

For feedback not related to this particular code, please click here.
 
To post feedback, first please login.


 

Categories | Articles and Tutorials | Advanced Search | Recommended Reading | Upload | Newest Code | Code of the Month | Code of the Day | All Time Hall of Fame | Coding Contest | Search for a job | Post a Job | Ask a Pro Discussion Forum | Live Chat | Feedback | Customize | ASP/ VbScript Home | Site Home | Other Sites | Open Letter from Moderators | About the Site | Feedback | Link to the Site | Awards | Advertising | Privacy

Copyright© 1997-2008 by Exhedra Solutions, Inc. All Rights Reserved.  By using this site you agree to its Terms and Conditions.   Planet Source Code (tm) and the phrase "Dream It. Code It" (tm) are trademarks of Exhedra Solutions, Inc.