Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsVB SyntaxEnterprise DevelopmentDatabase AccessControlsCOMWin APICrystal ReportDeploymentGeneralGeneral 2
Related Topics
VB.NET / ASP.NETMS SQL ServerMS AccessOther Database ProductsMore Topics ...

VB Forum / Database Access / January 2006



Tip: Looking for answers? Try searching our database.

ADO database mdb select datepart

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Pianto Tardivo - 26 Jan 2006 14:02 GMT
Hi.
I have a question....

I have a very simple table

date             in(numerical)            out(numerical)

If my records in table were (the date format is italian-date):

datedoc                            in                      out
25/01/2006                       10                      3
28/01/2006                       6                        9
12/02/2006                       5                       2
23/02/2006                       15                     12

I would like to obtain this result

month                         total_in                total_out
jenuary                            16                        12
february                           20                        14

I've tried with a select like this:

SELECT
   DATEPART(YEAR,DATEDOC) AS ANNO,
   DATEPART(MONTH, DATEDOC) AS MESE,
   SUM(IN) AS [TOTAL_IN],
   SUM(OUT) AS [TOTAL_OUT]
FROM MYTAB
GROUP BY DATEPART(YEAR,DATEDOC) , DATEPART(MONTH, DATEDOC)
ORDER BY ANNO, MESE

but I get an error...
Is it possible to use datepart with mdb database???
Is this selection string wrong????

Any suggestion will be very appreciated!!!!
Aatu-Matti - 26 Jan 2006 14:50 GMT
> Hi.
> SELECT
[quoted text clipped - 5 lines]
> GROUP BY DATEPART(YEAR,DATEDOC) , DATEPART(MONTH, DATEDOC)
> ORDER BY ANNO, MESE

Try ... ORDER BY 1 , 2    ie. result column position

Matti
Pianto Tardivo - 26 Jan 2006 15:32 GMT
>> Hi.
>> SELECT
[quoted text clipped - 9 lines]
>
> Matti

thank you very much Matti but it doesn't work!
Ralph - 26 Jan 2006 15:51 GMT
> Hi.
> I have a question....
[quoted text clipped - 33 lines]
>
> Any suggestion will be very appreciated!!!!

In what context are you using the select statement?

If using the SQL statement within ADO from a VBc application then you can
not use MS Access, nor VB internal functions in the statement. You can only
use standard SQL commands.

If this is an MS Access Query (built and stored in MS Access) then you can
use automation to call the query and thus run it inside MS Access. Otherwise
you will need to retrieve all the data and massage it yourself using VB
functions. (Or perhaps re-work the statement to be able to make multiple
calls.)

Please provide more information concerning where and how you are using this
Query, and version of MS Access you are using.

-ralph
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.