Author |
Topic |
wided
Posting Yak Master
218 Posts |
Posted - 2010-10-04 : 05:18:46
|
How to calculate the number of monthwhen i have 2 date(By using the functions date or others functions)exampleDate1 = '20100401' or other date given date ='20100630'if i use datediff , i have 2 months as a result, so i want to have 3thanksPS: sql2000 or sql2005 |
|
webfred
Master Smack Fu Yak Hacker
8781 Posts |
Posted - 2010-10-04 : 05:27:52
|
In your example the result of 2 is correct because june isn't finished. No, you're never too old to Yak'n'Roll if you're too young to die. |
|
|
wided
Posting Yak Master
218 Posts |
Posted - 2010-10-04 : 05:36:18
|
no webfredthe result may be 3month4, month5 and month6thanks |
|
|
webfred
Master Smack Fu Yak Hacker
8781 Posts |
Posted - 2010-10-04 : 06:09:14
|
What I meaned was if you take 20100701 instead of 20100630 then the result will be 3 because then the june is finished. No, you're never too old to Yak'n'Roll if you're too young to die. |
|
|
wided
Posting Yak Master
218 Posts |
Posted - 2010-10-04 : 06:16:50
|
The result between '20100701' and '20100630'must be zeroI want to calculate the interval of interruption in months between 2 dates this is my program |
|
|
wided
Posting Yak Master
218 Posts |
Posted - 2010-10-04 : 06:44:48
|
please I await your reply |
|
|
webfred
Master Smack Fu Yak Hacker
8781 Posts |
Posted - 2010-10-04 : 07:16:49
|
So let's say for the first date you are always giving the first day of the month i.e. 20100401 and for the second day you are always giving the last day of the month i.e 20100630 or for example 20100831.In this case you can add one day to the second date.select datediff(month,'20100401',dateadd(dd,1,'20100630'))Is that what you want? No, you're never too old to Yak'n'Roll if you're too young to die. |
|
|
webfred
Master Smack Fu Yak Hacker
8781 Posts |
|
wided
Posting Yak Master
218 Posts |
Posted - 2010-10-04 : 07:30:55
|
i hope soi think that is the unique solutionthanks |
|
|
webfred
Master Smack Fu Yak Hacker
8781 Posts |
Posted - 2010-10-04 : 07:32:01
|
welcome No, you're never too old to Yak'n'Roll if you're too young to die. |
|
|
|