Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

calculating weighted average of datetime field

Status
Not open for further replies.

Palpa

Programmer
Jul 11, 2011
17
US
Hi there,

i am trying to convert datetime field into numeric filed so that i can generate weighted average but every time to try to do that i am getting 'the string is non-numeric' error. What i am doing is converting datetime to string and then to number and then get the weighted average and convert that weighted average back to datetime. Can anyone let me know if crystal let datetime to change in to number and if yes then please guide me.

Any help regarding this will be greatly appreciated.

Thanks in Advance.
 
I've never heard of an average date or a weighted average of a date. Are you sure you aren't instead trying to determine the average of a date difference? Or the mode or Nth most frequent?

Anyway, you can convert a date to a number using:

datediff("d",date(1899,12,30),{table.date})

-LB
 
Yes, i was trying to get the weighted average of the date. But i couldn't do it with crystal. So i used 'Convert function to change the datetime into number and used that number calculate the weighted average and converted into date again.

Convert Function: CONVERT(bigint,CONVERT(datetime,MTLoanProperties.[OriginalInterestAdjustmentDate])) as "Original Or Renewed IAD"

Theh used this formula in crystal: dateadd ('d', 2, cdate (weightedaverage ({Command.Original Or Renewed IAD}, {Command.r2824 Outstanding Principal Balance}, {Command.PoolNumber})))

thanks for the help.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top