Function for Displaying Month

This is a discussion on "Function for Displaying Month" within the Classic ASP section. This forum, and the thread "Function for Displaying Month are both part of the Program Your Website category.



Go Back   Webforumz.com > Main Forums > Program Your Website > Classic ASP

Notices


Reply
 
LinkBack Thread Tools
  #1 (permalink)  
Old Aug 31st, 2006, 05:28
New Member
Join Date: Jul 2006
Location: Philippines
Age: 28
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Function for Displaying Month

hi everyone!

i want to have a function that will display the month as a string.

for example my input is "3/20/2006"

the output should be: "Month is Mar"

meaning 3 = Mar

if 11 = Nov, 12 = Dec .. and so on...


can anybody help me to do this?

thanks.
Reply With Quote

  #2 (permalink)  
Old Sep 2nd, 2006, 16:52
New Member
Join Date: Aug 2006
Location: Birmingham, UK
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Function for Displaying Month

Hi!

I think in ASP VBScript there is a MonthName function which you can use. First you need to cast the date string into a Date data type, then use the Month function to return the month number from that string, then use MonthName to return the name for that month. I think if you supply True as the second parameter, it will abbreviate the month name for you. So for example:
Code: Select all
Function GetMonthName(value)
    Dim dteValue
    Dim intMonth
    Dim strMonth
 
    dteValue = CDate(value)
    intMonth = Month(dteValue)
    strMtonh = MonthName(intMonth, True)
 
    GetMonthName = strMonth
End Function
You can encur all sorts of problems with dates though, because ASP can't handle different variable types, and so effectively treats every variable like a String. You might find that it gets confused between 10/03/2006 (October 3rd in US format) and 03/10/2006 (March 10th in US format), but it all depends on how you're storing your dates in the first place.

Hope that helps. Give me a shout if you need any more.
Reply With Quote
Reply

Tags
function, displaying, month

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
Just display the month? Jack Franklin PHP Forum 6 Feb 3rd, 2008 13:24
Problem with displaying random quotes from a function Z101 JavaScript Forum 3 Dec 7th, 2007 22:34
Site of the Month craig Entry, Nominations and Voting 0 Oct 18th, 2005 12:19
Website of the Month! Webforumz Staff Entry, Nominations and Voting 6 Feb 3rd, 2004 13:30


All times are GMT. The time now is 00:08.


Powered by vBulletin®
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC8
© 2003-2008 Webforumz.com : All Rights Reserved

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43