I am trying to build a query which will give me No of Years/Months/Days from Date. I have Date field (Date)and i have NoOfDays field (Numeric 10)(I am calculating No of Days from Date in NoOfDays field) now i want result where i need to show No Of years/Months/years from selected date. For e.g. Date = 07/26/2015 the Result should be - Years=0,Months=3,Days=13 For e.g. Date = 08/20/2014 the Result should be - Years=1,Months=2,Days=19 i tried with several ways but could not able to get desired result. |
I'm a bit confused what you really need. A Date doesn't have a number of years/months/days. Do you need the difference between the given date and today? If so, check out TIMESTAMPDIFF and EXTRACT functions. I need difference of Given Date and Today's date but in User Defined format i.e. Years=XX,Months=YY,Days=ZZ. (XX-no of years, YY-no of month, ZZ-no of days) User will add a date for e.g. "08/20/2014" i need to write a query which can give me output in this format - Years=1,Months=2,Days=19 whether ADS having readymade function? i tried with few queries but its not working as per expected...
(07 Nov '15, 14:49)
ninad
my query is
(07 Nov '15, 14:49)
ninad
there is no ready-made function because this is something wery specific. To get the distance between two date values in days, just substract one from the other: date1-date2. If you define a month always to be 30 days and a year always to be 365 days, then you can just calculate with that result.
(07 Nov '15, 20:21)
Joachim Duerr
|