Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
ntn104
Posting Yak Master
175 Posts |
Posted - 2014-09-29 : 11:40:01
|
I was trying to compare two date fields in two difference tablefor example: select a.date1, b.date2 from table1 a left join table2 b on b.id = a.id where date2 > dateadd(dd, -365, date1)but I got error message of numeric out of range.Please help me figure out what is going on. Both date fiels are format as Date.Thanks, |
|
Bustaz Kool
Master Smack Fu Yak Hacker
1834 Posts |
Posted - 2014-09-29 : 16:35:29
|
What value does Date1 have? Have you considered using DateDiff instead? Too often we enjoy the comfort of opinion without the discomfort of thought. - John F. Kennedy |
|
|
ntn104
Posting Yak Master
175 Posts |
Posted - 2014-09-29 : 17:18:59
|
Hi Busstaz Kool,I haven't try the datediff method. Here is example of date fields:DATE1 ='2013-08-25'DATE2 ='2014-09-29' If I used DATEDIFF, how can I calculate date2 >= date1 - 1 year(or365 days)?Thanks,quote: Originally posted by Bustaz Kool What value does Date1 have? Have you considered using DateDiff instead? Too often we enjoy the comfort of opinion without the discomfort of thought. - John F. Kennedy
|
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2014-09-30 : 08:29:13
|
If both the columns are of DATE datatype, you wont get an errorMadhivananFailing to plan is Planning to fail |
|
|
ntn104
Posting Yak Master
175 Posts |
Posted - 2014-09-30 : 09:46:00
|
Yes both of columns are DATE datatype. That was why I don't know why I got error. Thanks,quote: Originally posted by madhivanan If both the columns are of DATE datatype, you wont get an errorMadhivananFailing to plan is Planning to fail
|
|
|
|
|
|