|
-
Jan 14th, 2005, 11:49 AM
#1
Thread Starter
New Member
MonthName function
hi
i stored some dates in ms acces, and i'm using visual studio 6.0, visual basic 6.0
i used this sql statement to get the monthnumber out of the dates, stored as short date type.
month([cd.datum]) as maand.
this works
now i want to get the monthname out of the monthnumber
and i tried this
MonthName(month([cd.datum]),true) as maandnaam
Probably i'll get a syntax error too, but now i only get the following message
'expression contains an undefined function MonthName'
According to msdn.com,this function should be defined in vb 6.0 !
Do i have to update my visualstudio ?
where can i find those updates?
is my syntax right? (i want the monthname, abreviated = true)
thx
grtz,
w.
-
Jan 14th, 2005, 12:08 PM
#2
Re: MonthName function
You can get this with the Format function, but it would probably be easiest to retrieve the entire date, and then picking out the parts you need to manipulate. Here are a couple of examples:
VB Code:
Dim iMonth As Integer
Dim sDate as String
iMonth = 7 'July, for example
sDate = "01/14/2005"
sMonth = Format(sDate, "mmmm") 'Full name
sMonth = Format(sDate, "mmm") 'Short name
sMonth = Format(DateAdd("M", iMonth, 0), "mmmm") 'Month only
The first two work with a full date string (date type too), and the last one will return the name of an enumerated month.
-
Jan 14th, 2005, 12:09 PM
#3
Re: MonthName function
Something like this may work for you:
VB Code:
Private Sub Command2_Click()
Dim intMonth%
intMonth = Month(Now)
MsgBox Format(intMonth & "/" & Day(Now) & "/" & Year(Now), "mmmm")
End Sub
-
Jan 14th, 2005, 12:21 PM
#4
Re: MonthName function
 Originally Posted by RhinoBull
Something like this may work for you:
VB Code:
Private Sub Command2_Click()
Dim intMonth%
intMonth = Month(Now)
MsgBox Format(intMonth & "/" & Day(Now) & "/" & Year(Now), "mmmm")
End Sub
This would be dependant on the system's international date setting, whereas this is not:
VB Code:
MsgBox (Format(DateAdd("M", Month(Now), 0), "mmm"))
-
Jan 14th, 2005, 12:40 PM
#5
Re: MonthName function
 Originally Posted by Comintern
This would be dependant on the system's international date setting ...
That's why I said "something like ..."
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|