cr 9.0
ms sql
I have a {?Start_date} look like this 2007/05/22
i would like to add 30 days to this parameter at the day value
can i do this
Cdate(year({?Start_date}),month({?Start_date}),
day({?Start_date}+30))
Unfortunately, that would be attempting to do the following in your example:
Cdate(2007,5,52)
When that happens, it loops back to the 1st again, so the output of that would be 5/21/2007.
If you want to add 30 days and the parameter is a date, simply do the following:
{?StartDate}+30
output: 6/21/2007
Alternatively, if you want to add a month, do the following:
DateAdd("m",1,{?StartDate})
output: 6/22/2007
DateAdd is a very valuable function to understand. It's saved me a lot of headaches.
--
"I'm not talking to myself, I'm just the only one who's listening." - JCS
I was just giving options, and hadn't realized you already posted {?StartDate}+30 for the 30 days ahead.
There was a small error with parenthesis. If you want to do it they way you mentioned do the following:
dateserial(year({?Start_date}),month({?Start_date}),day({?Start_date})+30)
I understand they're not the same thing. I'm sorry for even posting an option that may have not been thought of. It was explicitly stated as a month, and even showed the output for comparison.
Yes, the parens affect it.
dateserial(year({?Start_date}),month({?Start_date}),day({?Start_date})+30)
Returns: 6/21/2007
Yes, I did test it before posting. I don't have 9.0, but it does the same thing in 8.5, XI, and XI R2.
I feel like I'm being attacked personally for trying to help. I'm sorry for invading on your territory, but don't start a vendetta against me for trying to help.
My apologies I didn't realize there was a difference.
Why wouldn't you have just shown the dateadd using "D" instead of "M as the requirements asked for?
Anyway seems a bit odd to me, hence my posting back.
Which you ignored and intead state that you're being attacked, rather than saying, you're correct, I should have posted it for 30 days as requested.
Curb the paranoia, you're not being attacked, but I am very direct, whereas you take different approaches.
The common ground is that we intend to help others, right?
So you're one of the good guys in my mind, however inaccurate in your post so I was curious why you intentionally elected to be.
Whereas I'm attacking you in your mind.
Never said a thing about you, I just addressed your post.
Whereas I immediately state that you are correct in that the paren should be moved, didn't pay much attention beyond whether the syntax was correct, I appreciate youcorrecting it - In my infinite laziness, I copied and pasted their formula and just changed it to dateserial.
So what does that say about us as professionals?
Well we couldn't work together as any disagreement would be viewed by you as an attack, and you don't amke errors, even when what you supply is wrong.
I tend to just toss out theory, and don't pay attention to details, resulting in errors when posting here because I try to assist too many people I s'pose.
Anyway, peace no attacks were being made here but you were incorrect (not theoretical) as was I.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.