Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
upaliwije
Creator II
Creator II

Date gap

I want to create a variable to find the no of days between two dates

Date field in my Table is From_Date

I want to create a date as 31-aug-2014 and

then find difference between

31-Aug-2014-from_date

Pls help me to create variable for this

1 Solution

Accepted Solutions
sundarakumar
Specialist II
Specialist II

in ur load script try this,

load ....,

num(makedate(2014,8,31))-num(from_date) as days_past,

.....

from xyz;

This will giv u a field called days_past which has the required number for each and every row. Since there are more than one row u cannot straight away save it to a variable.

Please explain ur requirement, may be a field will help in ur case. since we go for variable only in case of max date, min date, etc.

-Sundar

View solution in original post

12 Replies
maxgro
MVP
MVP

From_Date - makedate(2014,8,31)

anbu1984
Master III
Master III

How do you select particular From_Date?

Try like this

Load Max(From_Date) As Max_Dt From Table;

Let Dt = peek('Max_Dt') - Date#('8/31/2014','M/D/YYYY');

TRACE $(Dt);

upaliwije
Creator II
Creator II
Author

Thanks

How can I store this in a variable. Pls explain

upaliwije
Creator II
Creator II
Author

From Date is recorded in the table against each record

anbu1984
Master III
Master III

So do you want calculate difference for all rows or one row?

upaliwije
Creator II
Creator II
Author

FOR ALL ROWS

maxgro
MVP
MVP

see attachment

upaliwije
Creator II
Creator II
Author

THAKS FOR YOUR REPLY

BUT IT IS STILL NOT WORKING IN MY MODULE. I HAVE RECORDED FROM_DATE IN THE FOLLOWING FORMAT. IS THAT THE REASON ?

date(floor(FROM_DATE),'DD-MMM-YYYY')AS  FROM_DATE,

sundarakumar
Specialist II
Specialist II

in ur load script try this,

load ....,

num(makedate(2014,8,31))-num(from_date) as days_past,

.....

from xyz;

This will giv u a field called days_past which has the required number for each and every row. Since there are more than one row u cannot straight away save it to a variable.

Please explain ur requirement, may be a field will help in ur case. since we go for variable only in case of max date, min date, etc.

-Sundar