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


FLASHBACK WITH SIRASA FM AT GALGAMUWA 2022


Mp3 Download: Mdu - Mazola


Imitation gun was fired at motorist in Leicester road-rage incident


Ndebele names


MCKINNEY EMALINE “EMMA” OF WES...


Okra & Motia — The Workshop (Prod by Hammer)


Skint TV teen to be sentenced


Moondru Mudichu 19-09-2017 – Polimer tv Serial


YOSVANI JAMES Arrested by Miami-Dade County Corrections on Jan 10, 2017


Stories • Goddess Stepmom



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