468,242 Members | 1,575 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,242 developers. It's quick & easy.

Cast

OuTCasT
374 256MB
hi all

could i please find out what is wrong with this select statement ?

Expand|Select|Wrap|Line Numbers
  1. SELECT INV_CheckNum, INV_CheckAmt, INV_DiscountAmt, INV_PaidAmt, INV_VendorNumOrig, INV_VendorName, RNDOC, Days, Years,CAST(DateAdd(day,Days('1/1/'+'200'+Years)as smalldatetime) as DateStart
i get this error

Arithmetic overflow error converting expression to data type smalldatetime
Oct 31 '08 #1
1 1164
code green
1,726 Expert 1GB
It is a data type error somewhere in here
Expand|Select|Wrap|Line Numbers
  1. CAST(DateAdd(day,Days('1/1/'+'200'+Years)
  2. as smalldatetime) as DateStart 
Debug this by removing the wrapper functions and 'seeing' what is there.
Then add a function wrapper at a time and check what is there again. ie
Expand|Select|Wrap|Line Numbers
  1. day
Expand|Select|Wrap|Line Numbers
  1. Days('1/1/'+'200'+Years) 
then
Expand|Select|Wrap|Line Numbers
  1. DateAdd(day,Days('1/1/'+'200'+Years)as smalldatetime 
then
Expand|Select|Wrap|Line Numbers
  1. CAST(DateAdd(day,Days('1/1/'+'200'+Years)
  2. as smalldatetime) as DateStart 
Oct 31 '08 #2

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

reply views Thread by Aaron W. West | last post: by
3 posts views Thread by Mike | last post: by
3 posts views Thread by mra | last post: by
5 posts views Thread by Nick Flandry | last post: by
6 posts views Thread by Lore Leunoeg | last post: by
9 posts views Thread by Frederick Gotham | last post: by
5 posts views Thread by Frederick Gotham | last post: by
7 posts views Thread by * Tong * | last post: by
reply views Thread by kermitthefrogpy | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.