Solved

# Calculated Date Field in Dw

Posted on 2006-06-15
347 Views
How can I do the calculated date  in the dw with Computed  field.
I have a Computed Field where I calculate the number of months the item expire in.
Now, based on that I need to report the month when the part expire.

Ex.
Remaining Hours 400
Remaining Months 400/180 ( 180 &#1095;&#1072;&#1089;&#1086;&#1074; &#1074; &#1084;&#1077;&#1089;&#1103;&#1094; &#1093;&#1072;&#1088;&#1076;&#1082;&#1086;&#1076;&#1077;&#1076;)= 2
Expire Months 2

Expire Date needed Todays date + 2 months = August, 2006...

How to do the calculations for the date.
In SQL I could do the Dateadd, but how do I do that in Dw.

thanks

0
Question by:Namik48075
[X]
###### Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

• Help others & share knowledge
• Earn cash & points
• 2
• 2

LVL 4

Expert Comment

ID: 16914587
Look at the RelativeDate Function.
0

Author Comment

ID: 16914696
Thank you,

Is the relative date only works with days, is it possible something like thins for months?
0

LVL 4

Accepted Solution

Lordain earned 250 total points
ID: 16915155
If you are only after the month then Try this:

Long ll_month

ll_month = Month ( Today( ) ) // Should return the Month of the Today( June = 6)

Now all you need to do is add 2 to the return value.  You will likely need logic to handle the case if you exceed month 12 but that should be easy.

ll_month + 2

You can also do Year ( Today( ) ) should you want to involve years too.
0

LVL 8

Expert Comment

ID: 16921407
you can try this

If((400/180)+2>12,13 - (400/180)+2, (400/180)+2) make a compute filed with the name c_month
The creat another computete file like this

If(c_month=1,’Jan’,if(c_month=2,’Feb’, if(c_month=3,’March’, if(c_month=4,’April’, if(c_month=5,’May’, if(c_month=6,’june’, if(c_month=7,’July’, if(c_month=8,’August’, if(c_month=9,’Sep’, if(c_month=10,’OCT’, if(c_month=11,’Nov’, if(c_month=12,’DEC’,))))))))))))
0

LVL 8

Expert Comment

ID: 16921417
sorry for mistyping

you can try this

If((400/180)+2>12,13 - (400/180)+2, (400/180)+2) make a compute filed with the name c_month and hide it
Then creat another computed filed like this

If(c_month=1,’Jan’,if(c_month=2,’Feb’, if(c_month=3,’March’, if(c_month=4,’April’, if(c_month=5,’May’, if(c_month=6,’june’, if(c_month=7,’July’, if(c_month=8,’August’, if(c_month=9,’Sep’, if(c_month=10,’OCT’, if(c_month=11,’Nov’, if(c_month=12,’DEC’,))))))))))))
0

## Featured Post

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

### Suggested Solutions

JTable - Group/UnGroup/Drag&Drop 2 111
Windows 8 - Determine what application / process "owns" the F11 key. 4 78
Java eclipse error 2 77
Visual Studio 2013 and Eclipse Neon 6 102
In our object-oriented world the class is a minimal unit, a brick for constructing our applications. It is an abstraction and we know well how to use it. In well-designed software we are not usually interested in knowing how objects look in memory. …
Jaspersoft Studio is a plugin for Eclipse that lets you create reports from a datasource.  In this article, we'll go over creating a report from a default template and setting up a datasource that connects to your database.
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
The viewer will learn how to use and create new code templates in NetBeans IDE 8.0 for Windows.
###### Suggested Courses
Course of the Month4 days, 10 hours left to enroll