Need Days from two Dates

Post questions here relative to DataStage Enterprise/PX Edition for such areas as Parallel job design, Parallel datasets, BuildOps, Wrappers, etc.

Moderators: chulett, rschirm, roy

Post Reply
krisp321
Participant
Posts: 39
Joined: Thu Mar 04, 2010 12:39 am

Need Days from two Dates

Post by krisp321 »

Hi
I am trying to get no. of days from two dates.

Source dates
Date1 Date2
10/23/2010 10/25/2010
10/20/2010 10/22/2010
10/19/2010 10/22/2010

Read as varchars and converted to date format using stringtodate func.
Now Date1 and Date2 are date datatypes
Date1 Date2
2010-10-23 2010-10-25
2010-10-20 2010-10-22
2010-10-19 2010-10-22

Now in transformer
if i do
Date1-Date2 to get no. of days
output is Integer
I am getting an error
Invalid consertion from date to dfloat

any suggestion is greatly appreciated

Thanks in advance
Kris
swapnilverma
Participant
Posts: 135
Joined: Tue Aug 14, 2007 4:27 am
Location: Mumbai

Re: Need Days from two Dates

Post by swapnilverma »

plz try below function

DaysSinceFromDate

It Returns the number of days from source date to the given date
source_date given_date

Let us know if u face any issue ?
Thanks
Swapnil

"Whenever you find whole world against you just turn around and Lead the world"
krisp321
Participant
Posts: 39
Joined: Thu Mar 04, 2010 12:39 am

Re: Need Days from two Dates

Post by krisp321 »

hi
I tried, I did not get expected result
here is what I tried
DaysSinceFromDate(Date1) - DaysSinceFromDate(Date2)
anbu
Premium Member
Premium Member
Posts: 596
Joined: Sat Feb 18, 2006 2:25 am
Location: india

Post by anbu »

Code: Select all

DaysSinceFromDate(Date1,Date2)
You are the creator of your destiny - Swami Vivekananda
naveen.p
Participant
Posts: 55
Joined: Sat Nov 21, 2009 5:19 am
Location: Chennai

Post by naveen.p »

Hi,

anbu Wrote
--------------------------------------------------------------------------------

Code:
DaysSinceFromDate(Date1,Date2)

---------------------------------------------------------------------

DaysSinceFromDate(Date Column, Format Specifier).

Can we mention a second date to find the difference?

Thanks
Naveen
anbu
Premium Member
Premium Member
Posts: 596
Joined: Sat Feb 18, 2006 2:25 am
Location: india

Post by anbu »

Yes
You are the creator of your destiny - Swami Vivekananda
krisp321
Participant
Posts: 39
Joined: Thu Mar 04, 2010 12:39 am

Post by krisp321 »

anbu wrote:

Code: Select all

DaysSinceFromDate(Date1,Date2)
I tried but this is not working. I am just getting 0 days. I am not getting exact days. I am trying to load the difference into integer datatype. Does this makes any diff.?
mailravi.dw@gmail.com
Participant
Posts: 19
Joined: Sat Dec 19, 2009 8:50 am
Location: Chennai

Post by mailravi.dw@gmail.com »

I am assuming Date1 and Date2 attributes are varchar and provided the below Derivation.

Derivation: DaysSinceFromDate(StringToDate(Date1,"%mm/%dd/%yyyy"), StringToDate(Date2,"%mm/%dd/%yyyy"))

This function returns the interger (int32) value.
naresh_kakarla
Participant
Posts: 2
Joined: Thu Nov 18, 2010 6:17 am
Location: hyderabad

Post by naresh_kakarla »

convert date formate to integer format by using juliandays from date and then you use '-' operator
Thanks
Naresh
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

So, what was your actual resolution?
-craig

"You can never have too many knives" -- Logan Nine Fingers
Post Reply