Search code examples
subsonicdistinctsimplerepository

Get distinct month and year with SubSonic


I have date type column (MySQL):

SELECT invdate FROM invoices;

invdate
-------
2009-08-22
2009-07-12
2009-08-23
-------

and I want get month and year like this:

SELECT DISTINCT MONTH(invdate) AS invmonth, YEAR(invdate) AS invyear FROM invoices;

how to use in C# with SubSonic (SimpleRepository)?

TIA


Solution

  • OMG! I forgot to define variable as date/datetime, so I can not use these functions.

    before:

    public string invdate { get; set; }
    

    after:

    public DateTime invdate { get; set; }
    

    My mistake, I'm sorry. Problem solved.