Count how may days in a month in elixir

  def dashboard_params(param) do
    "Transactions"
    |> join(
         :right,
         [c],
         day in fragment("""
         SELECT CAST(DATEADD(DAY, nbr - 1, DATEADD(month, DATEDIFF(month, 0, CAST(CURRENT_TIMESTAMP AS DATETIME)), 0)) AS DATE) d
         FROM (
         SELECT ROW_NUMBER() OVER (ORDER BY c.object_id) AS Nbr
         FROM sys.columns c
         ) nbrs
         WHERE nbr - 1 <= DATEDIFF(DAY, DATEADD(month, DATEDIFF(month, 0, CAST(CURRENT_TIMESTAMP AS DATETIME)), 0), EOMONTH(CAST(CURRENT_TIMESTAMP AS DATETIME)))
         """),
         day.d == fragment("CAST(? AS DATE)", c.inserted_at)
       )
    |> group_by([c, day], [day.d,  c.voucher_provider])
    |> order_by([_c, day], day.d)
    |> select([c, day], %{
      day: fragment("convert(varchar, ?, 107)", day.d),
      count: count(c.id),
      status:  c.voucher_provider
    })
    |> Repo.all()
  end

β€œtransactions” is the name of the table…
the code above is one i want to query how many days are in a mouth based on the first of the month to-day … but i sim to get an error on |> join…saying no function clause mathcing ecto.query.join/5. what is the best way i can achieve this

Hello, please use code fence ``` around your code to make it more readable :slight_smile:

2 Likes

<% datetime_data = Poison.encode!(%{
β€œ2013-02-10 00:00:00 -0800”: 11,
β€œ2013-02-11 00:00:00 -0800”: 6,
β€œ2013-02-12 00:00:00 -0800”: 3,
β€œ2013-02-13 00:00:00 -0800”: 2,
β€œ2013-02-14 00:00:00 -0800”: 5,
β€œ2013-02-15 00:00:00 -0800”: 3,
β€œ2013-02-16 00:00:00 -0800”: 8,
β€œ2013-02-17 00:00:00 -0800”: 6,
β€œ2013-02-18 00:00:00 -0800”: 6,
β€œ2013-02-19 00:00:00 -0800”: 12,
β€œ2013-02-20 00:00:00 -0800”: 5,
β€œ2013-02-21 00:00:00 -0800”: 5,
β€œ2013-02-22 00:00:00 -0800”: 3,
β€œ2013-02-23 00:00:00 -0800”: 1,
β€œ2013-02-24 00:00:00 -0800”: 10,
β€œ2013-02-25 00:00:00 -0800”: 1,
β€œ2013-02-26 00:00:00 -0800”: 3,
β€œ2013-02-27 00:00:00 -0800”: 2,
β€œ2013-02-28 00:00:00 -0800”: 3,
β€œ2013-03-01 00:00:00 -0800”: 2,
β€œ2013-03-02 00:00:00 -0800”: 8
}) %>

Line chart

<%= raw Chartkick.line_chart datetime_data %>

good morning this is the chart i want use… i want to display in the y axis the dates from the beginging of the week today… how do i feed that data in this chart