sql - how to replace overflows with NULL? -


how replace invalid datetime null?

i doing operations on int column date representation:

select    dateadd(dd, rbaging.billing_period_end - 693594, '1900-01-01'), dateadd(dd, rbaging.billing_period_apply - 693594, '1900-01-01'),  *      [kslap208].[c021]..rb_resident_aging  rbaging  join [kslap208].[c021]..pa_profile_base_1119 pro on rbaging.bill_to_profile_id=pro.profile_id   --4242  join  [kslap208].[c021]..pa_admit_det_base_10 unit on unit.profile_id=rbaging.bill_to_profile_id 

the rbaging table integer fields supposed dates. here's sample:

734562 734776 734837 

the documentation states convert int date way:

enter image description here

when running sql statement above, getting:

msg 517, level 16, state 1, line 1 adding value 'datetime' column caused overflow. 

how replace invalid datetime null?

case when (rbaging.billing_period_end - 693594)>1 dateadd(dd, rbaging.billing_period_end - 693594, '1900-01-01') else '' end,  case when (rbaging.billing_period_apply - 693594)>1 dateadd(dd, rbaging.billing_period_apply - 693594, '1900-01-01') else '' end 

works charm!


Comments

Popular posts from this blog

c# - DetailsView in ASP.Net - How to add another column on the side/add a control in each row? -

javascript - firefox memory leak -

Trying to import CSV file to a SQL Server database using asp.net and c# - can't find what I'm missing -