Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 Other Forums
 MS Access
 Access equivalent of cast

Author  Topic 

kaus
Posting Yak Master

179 Posts

Posted - 2004-04-20 : 17:43:33
I want to group my data by month-year I've got the following query:
SELECT Sites.SiteNo, Avg( [Monthly_BOD/TSS].BOD_mgl) as BOD_AVG, Avg([Monthly_BOD/TSS].TSS_mgl) as TSS_AVG, MonthName([Monthly_BOD/TSS].Sample_Date) & "-" & cast(Year([Monthly_BOD/TSS].Sample_Date) , text) as yr
FROM Sites Inner JOIN [Monthly_BOD/TSS] ON Sites.SiteNo = [Monthly_BOD/TSS].SiteNo
Group by Sites.SiteNo,MonthName([Monthly_BOD/TSS].Sample_Date) & "-" & cast(Year([Monthly_BOD/TSS].Sample_Date) , text) as yr

sample date values are like jan-25-2003

I'm getting missing operator error in query expression -- I'm thinking the Year() function returns an integer and I need to convert to string --

Thanks

Pete

kaus
Posting Yak Master

179 Posts

Posted - 2004-04-20 : 18:00:56
Nevermind -- I got it
Format([Monthly_BOD/TSS].Sample_Date, "mmm yyyy")
Go to Top of Page

mohdowais
Sheikh of Yak Knowledge

1456 Posts

Posted - 2004-04-21 : 01:44:40
Just FYI, to cast a value to string in Access, you can use the CStr() function.

OS
Go to Top of Page
   

- Advertisement -