Question: I have a mysql query.

The idea is to select the records between a date range. The dates are stored as unix timestamps. With the query below, I end up with far more records than I should (out of the date range).

I have picked my brain and I cant see where the query is going wrong. The other fields look correct, its just that I am out of the desired date range.

```
SELECT
        mdl_user_info_data.data,
        mdl_user.firstname, 
        mdl_user.lastname, 
        mdl_grade_grades.itemid, 
        mdl_grade_items.itemname,
        mdl_quiz.fcpd,
        mdl_user_info_data.id,
        mdl_grade_grades.timecreated AS DATE
        FROM mdl_grade_grades
        INNER JOIN mdl_user ON mdl_grade_grades.userid = mdl_user.id
        INNER JOIN mdl_grade_items ON mdl_grade_grades.itemid = mdl_grade_items.id
        INNER JOIN mdl_quiz ON mdl_grade_items.courseid = mdl_quiz.course
        INNER JOIN mdl_user_info_data ON mdl_user.id = mdl_user_info_data.userid
        INNER JOIN mdl_course ON mdl_grade_items.courseid = mdl_course.id
        WHERE mdl_grade_grades.timecreated BETWEEN (FROM_UNIXTIME(1371704400) AND       FROM_UNIXTIME(1371790800))
        AND mdl_user_info_data.fieldid = 1
        AND mdl_grade_items.itemname IS NOT NULL
        AND mdl_course.category = 27
        OR mdl_grade_items.itemname LIKE '%asa%'
        GROUP BY mdl_user.firstname, mdl_user.lastname, mdl_grade_grades.timecreated

```

Answer: 
AFAIK, the svc is useless if you are not working with IIS. Outside of IIS, the so called self hosted approach, needs you to write a something like this, where HelloWorldWcfServiceMessage is your type implementing the service contract. Additionaly, don't forget to configure an endpoint for the server and to make sure you are allowed to open a service on the configured port. The following code you can use in windows service or in a console program (better for testing and debugging). Hope that helps and I got your question right.

```
...
this.serviceHost = new ServiceHost(typeof(HelloWorldWcfServiceMessage));
this.serviceHost.Open();
...

public class HelloWorldWcfServiceMessage : IHelloWorldWcfServiceMessage
{

}

[ServiceContract(Namespace = "http://HelloWorldServiceNamespace", Name = "PublicHelloWorldWCFService")]
public interface IHelloWorldWcfServiceMessage
{
    [OperationContract]
    string HelloWorldMessage(string name);
}

```
**Solved this**

This is all about Publishing a WCF service on IIS 8

All the credits goes to György Balássy

WCF services don’t run on IIS 8 with the default conჁguration, because the webserver doesn’t know, how to handle incoming requests targeting .svc Ⴡles. You can teach it in two steps:

Please check the same answer here.

<https://stackoverflow.com/a/45979587/3059688>