Manufacturing Information Solutions Forum Index Manufacturing Information Solutions
Your Place for Support and Discussions
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Convert Month names to short form abreviations and others

 
Post new topic   Reply to topic    Manufacturing Information Solutions Forum Index -> Microsoft Access
View previous topic :: View next topic  
Author Message
mistux
Site Admin


Joined: 25 Jun 2004
Posts: 1042
Location: South Bend, Indiana USA

PostPosted: Wed Sep 26, 2007 12:33 pm    Post subject: Convert Month names to short form abreviations and others Reply with quote

Here are some samples to deal with converting months names to numbers.

Code:

Public Function getMonthNum(MonthName As String) As Integer

Dim retVal As Integer

Select Case MonthName
    Case "January", "Jan"
        retVal = 1
    Case "February", "Feb"
        retVal = 2
    Case "March", "Mar"
        retVal = 3
    Case "April", "Apr"
        retVal = 4
    Case "May"
        retVal = 5
    Case "June", "Jun"
        retVal = 6
    Case "July", "Jul"
        retVal = 7
    Case "August", "Aug"
        retVal = 8
    Case "September", "Sep", "Sept"
        retVal = 9
    Case "October", "Oct"
        retVal = 10
    Case "November", "Nov"
        retVal = 11
    Case "December", "Dec"
        retVal = 12
End Select

getMonthNum = retVal

End Function


And

Code:

Assume your month is coming from a text box on a form...

Dim strMonth As String
Dim intMonth As Integer

strMonth = Me.txtMonth

intMonth = Month(1 & " " & strMonth)


Code:

Function GetMonthInt (strMonth as String) as Integer

GetMonthInt = Month(1 & " " & strMonth)

End Function

Then you can call it in a piece of code by using...

Dim intMonth as integer
intMonth = GetMonthInt(Me.txtMonth)

or edit the parameter to use it in a query.
Back to top
View user's profile Send private message Send e-mail
Display posts from previous:   
Post new topic   Reply to topic    Manufacturing Information Solutions Forum Index -> Microsoft Access All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group