Quote:
quote:Originally posted by daisy_polly
I am having some problem with this query:
SELECT Jaso.dan_LOBTB028PATENT,
(DAYS(CURRENT_DATE)-DAYS(jason.datecreated))/30
FROM Video
In the line where the days function starts this whole line is getting the diffrence between todays date and the date in the column(Datecreated) field. Right now I am getting a number like 12 or 6. I cannot get decimals so how can I get the decimals to show also. For example like 12.6 or 6.3.
|
The DAY function (that's what you meant, right? There is no DAYS function) returns the day portion of a datetime as an integer. Since you are computing the difference between two integers, the result is an integer. You then divide by an integer (30) so by default the division is integer division and the result is an integer. This conversion truncates any fractional part.
Try dividing by a decimal number to force the expression to be evaluated as a decimal number instead; your expression would then be something like:
Code:
SELECT (DAY(current_date)-DAY(jason.datecreated)) / 30.0
This by default give the result to 4 decimal places; you can use CAST/CONVERT to alter the precision of the result.
Jeff Mason
Custom Apps, Inc.
www.custom-apps.com