Quantcast
Channel: Transact-SQL forum
Viewing all articles
Browse latest Browse all 23857

Conversion failed when converting date and/or time from character string

$
0
0

Hi All,

I am trying to run the following query and it gives me the error

declare @StartDate date, @EndDate date

set @StartDate = dateadd(month, datediff(month, '19000101', CURRENT_TIMESTAMP) - 3, '19000101') 

SET @EndDate = CURRENT_TIMESTAMP
select * 
 From       ODS.Staging.vODS_GLBalance
    Inner Join Ods.JJill.tODS_GLBalance 
											ON tODS_GLBalance.FiscalYearId				= vODS_GLBalance.FiscalYearId
											AND tODS_GLBalance.FiscalMonthOfYearId		= vODS_GLBalance.FiscalMonthOfYearId
											AND tODS_GLBalance.Page                     = vODS_GLBalance.PAGE

											
	Where 
	
 CONVERT(date, cast(vODS_GLBalance.FiscalYearId as CHAR(4)) +   RIGHT('00'+CAST(vODS_GLBalance.FiscalMonthOfYearId  as VARCHAR(2)),2) + '01', 112) BETWEEN @StartDate and @EndDate 
	AND tODS_GLBalance.Balance <>  vODS_GLBalance.GLAmount


The vODS_GLBalance.FiscalYearId and vODS_GLBalance.FiscalMonthOfYearId are both Int columns, Can someone please help me with this.

Thanks


Viewing all articles
Browse latest Browse all 23857

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>