0

My following code is only retrives number month(1,2,3,4....12) and not month name(January,February,.....December). Can anyone help me to retrieves month name in sql query. Before that i had try using function datepart, Monthname and date_format but i still din get my answer.Thanks

con.ConnectionString = "PROVIDER=Microsoft.Jet.OLEDB.4.0;Data Source = C:\YS.mdb"
        con.Open()

        sql = "SELECT DISTINCT MONTH(dates) As [dates] FROM summary WHERE plants = '" & yieldsummary.cbPlant.Text & "' AND Year(dates) = " & cbYear.Text & "AND line = '" & cbLine.Text & "'"
        da = New OleDb.OleDbDataAdapter(sql, con)
        da.Fill(ds, "summary")

        con.Close()
2
Contributors
4
Replies
6
Views
7 Years
Discussion Span
Last Post by TomW
0
Select Distinct DATENAME(mm, CONVERT(CHAR(19), [dates])) AS [dates] From....

That will fomat the name of the month to be returned. However concatenating query strings like that is very poor programming format. You should look into how to convert that and use parameters.

0

:(

I TRY the coding already but come out "Undefined function'DATENAME' in expression. So i am wonder why it is happen bacause last time i also got the same error.

0

DateName must be specific to Sql Server which im more familiar with. There should be an equivlant type function in Access, its just a matter of looking up the syntax in its help file.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.