Page 1 of 1

Need Days from two Dates

Posted: Fri Nov 19, 2010 7:37 am
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

Re: Need Days from two Dates

Posted: Fri Nov 19, 2010 7:56 am
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 ?

Re: Need Days from two Dates

Posted: Fri Nov 19, 2010 10:50 am
by krisp321
hi
I tried, I did not get expected result
here is what I tried
DaysSinceFromDate(Date1) - DaysSinceFromDate(Date2)

Posted: Fri Nov 19, 2010 11:29 am
by anbu

Code: Select all

DaysSinceFromDate(Date1,Date2)

Posted: Fri Nov 19, 2010 1:20 pm
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

Posted: Fri Nov 19, 2010 1:36 pm
by anbu
Yes

Posted: Fri Nov 19, 2010 9:01 pm
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.?

Posted: Sat Nov 20, 2010 12:49 am
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.

Posted: Sun Nov 21, 2010 3:29 am
by naresh_kakarla
convert date formate to integer format by using juliandays from date and then you use '-' operator

Posted: Sun Nov 21, 2010 7:48 am
by chulett
So, what was your actual resolution?