Closed AhmadShamli closed 3 years ago
Hi, is there a way to use declare in the query.? using medoo 1.4.5 currently it returned empty.
example query: declare @StartDate DATETIME='2016-05-01 00:00:00' declare @EndDate DATETIME=getdate() SELECT cast(YEAR(DATEADD(MONTH, x.number, @StartDate)) as varchar) + '-' + cast(RIGHT('0' + RTRIM(MONTH(DATEADD(MONTH, x.number, @StartDate))), 2) as varchar) as Months FROM master.dbo.spt_values x WHERE x.type = 'P' AND x.number <= DATEDIFF(MONTH, @StartDate, @EndDate)
declare @StartDate DATETIME='2016-05-01 00:00:00' declare @EndDate DATETIME=getdate() SELECT cast(YEAR(DATEADD(MONTH, x.number, @StartDate)) as varchar) + '-' + cast(RIGHT('0' + RTRIM(MONTH(DATEADD(MONTH, x.number, @StartDate))), 2) as varchar) as Months FROM master.dbo.spt_values x WHERE x.type = 'P' AND x.number <= DATEDIFF(MONTH, @StartDate, @EndDate)
There is no direct way for this. But you can use query() or Medoo::raw for that.
query()
Medoo::raw
https://medoo.in/api/query https://medoo.in/api/raw
Hi, is there a way to use declare in the query.? using medoo 1.4.5 currently it returned empty.
example query:
declare @StartDate DATETIME='2016-05-01 00:00:00' declare @EndDate DATETIME=getdate() SELECT cast(YEAR(DATEADD(MONTH, x.number, @StartDate)) as varchar) + '-' + cast(RIGHT('0' + RTRIM(MONTH(DATEADD(MONTH, x.number, @StartDate))), 2) as varchar) as Months FROM master.dbo.spt_values x WHERE x.type = 'P' AND x.number <= DATEDIFF(MONTH, @StartDate, @EndDate)