Problem with an SQL query in VB.NET

dinak

New member
Joined
Nov 29, 2004
Messages
2
Programming Experience
1-3
Hello guys, newbie here.

Ive been tinkering with VB.NET's database functions lately and I became drowned by a single problem.

I tested this query against MS ACCESS. Im trying to get all the absences of empid 1.

SELECT COUNT(empid)
FROM absences
WHERE empid=4 And FORMAT(date_incurred,'mmmm')="MARCH"

I have an array of months in my application and each element is in text.
The format for date_incurred is dd/mm/yyyy in Ms Access.


What i want to do is to get the month in text format so i can compare it to


My current (and erroneous) code to get the number of absences of an employee in March in VB.NET is :

count = get_results("select empid from absences where empid=" & Me.empid & " and FORMAT(date_incurred,<<what should i write here?>>)=" & "MARCH").Rows.Count

Hoping for your immediate response.

More power!!!
 

TPM

Well-known member
Joined
Dec 7, 2004
Messages
623
Location
CA
Programming Experience
3-5
Well as far as I'm aware Format isn't an SQL function, also i think it would be MMMM not mmmm as that would be mins. If you can't use 'Where date_incurred = date' (date in dd/MM/yy) I'd suggest adding another column to the DB with the month as text. Or you could query all of it and do the count with VB (instead of SQL)

Hope this helps

TPM
 

dinak

New member
Joined
Nov 29, 2004
Messages
2
Programming Experience
1-3
Hey thanx for the reply. Ill give it a try today :)
 

TPM

Well-known member
Joined
Dec 7, 2004
Messages
623
Location
CA
Programming Experience
3-5
No problem, if you have any problems just ask.

TPM
 
Top Bottom