Showing posts with label dates. Show all posts
Showing posts with label dates. Show all posts

Thursday, March 22, 2012

Creating a table

I have a recordset that consists of among other things a list of values and
dates over the next 12 months, I want to display these dates in a table
ie
Jan Feb Mar Apr May Jun etc
12 80 120 5 65 56 etc
The months are on a 12 month rolling table, how would i achieve this,
perhaps using a case statement or ?
thanks in anticipation
JohnYes, I would do that to. Due to the fact that there will be no more
month (names) in the future this should be an appropiate solution. If
the tables is VERY big and the values seldom change in that table and
the query time must be fast you should thing about (if they are
aggregatable) using AS for this. This could speed up your performance
and let you (with the help of a time dimension) give you the possibilty
to aggregate the values fast from different views.
HTH, jens Suessmeyer.|||Can you give me some pointers of how to acheive this please ?
"Jens" <Jens@.sqlserver2005.de> wrote in message
news:1137772267.696338.62730@.g49g2000cwa.googlegroups.com...
> Yes, I would do that to. Due to the fact that there will be no more
> month (names) in the future this should be an appropiate solution. If
> the tables is VERY big and the values seldom change in that table and
> the query time must be fast you should thing about (if they are
> aggregatable) using AS for this. This could speed up your performance
> and let you (with the help of a time dimension) give you the possibilty
> to aggregate the values fast from different views.
> HTH, jens Suessmeyer.
>|||Sure, do you need information for AS or the setbased solution ? For the
set based solution it would be interesting to get some DDL and sample
data from your database. http://www.aspfaq.com/5006, otherwise a
generic solution would be
SELECT
CASE MONTH(DateColumn)
WHEN 1 THEN SUM(SomeValue) END As January (...)
HTH, jens Suessmeyer.

Friday, February 24, 2012

Creating a Boolean EvalExpression comparing dates

To the experts in the field:

There is probably a very simple solution that is avoiding my grasp.

I have a For Loop which I want to execute as long as a variable called BeforeRunDt = CurrentDate. Both are DateTime data types and I am using the following expression:

@.BeforeRunDt==@.CurrenDate

I get an error stating "Cannot convert expression value to propeerty type"

I understand that the result of the expression should be a boolean value but am just struggling on how to create it.

Thanks!

I believe that the following will work:

@.BeforeRunDt == @.CurrentDate ? True : False

Edit: You would set the variable to type boolean, and evaluate as expression to true with the above as the expression...

|||

Wow! Now I feel really stupid. After all the fuss I figured that I needed a For Each Loop instead and so I am back at square one trying to learn how to use that transform.

Thank you very much for taking the time to respond to my question!

|||

desibull wrote:

Wow! Now I feel really stupid. After all the fuss I figured that I needed a For Each Loop instead and so I am back at square one trying to learn how to use that transform.

Thank you very much for taking the time to respond to my question!

I would still have expected the expression in your first post to work.

Try replacing it with

(DT_BOOL)(@.BeforeRunDt==@.CurrenDate)

and see if it works.

cheers

Jamie

|||I was slightly surprised that his first expression wouldn't work as well... but if it isn't cast to the proper type that kind of makes sense I suppose...|||

EWisdahl wrote:

I was slightly surprised that his first expression wouldn't work as well... but if it isn't cast to the proper type that kind of makes sense I suppose...

Yeah. it could be similar to the issue talked about here:

NULLs in expressions gotcha

(http://blogs.conchango.com/jamiethomson/archive/2006/10/12/SSIS_3A00_-NULLs-in-expressions-gotcha.aspx)

-Jamie