-1

I have two field named BirthDate and exitDate (exit from hospital) in this format for example 20170921 as BirthDate , 20180103 As Exitdate. i want to calculate the age of patient from birthdate untill Exitdate from our hospital i want age in year and month what is the solution in this case? i design a dashboard in Qlik Sense i want a formula for this

KARTHIKEYAN.A
  • 18,210
  • 6
  • 124
  • 133
Pooneh.T
  • 9
  • 1
  • 4
  • 1
    What is the underlying database? – Tim Biegeleisen Jan 03 '18 at 09:07
  • 1
    Possible duplicate of https://stackoverflow.com/questions/14119277/subtract-two-dates-in-sql-and-get-days-of-the-result#14119294 – Héctor Álvarez Jan 03 '18 at 09:08
  • 1
    Possible duplicate of [Subtract two dates in SQL and get days of the result](https://stackoverflow.com/questions/14119277/subtract-two-dates-in-sql-and-get-days-of-the-result) – Héctor Álvarez Jan 03 '18 at 09:08
  • Are you looking for an algorithm? Or do you have an algorithm (which you forgot to tell us) and are stuck somewhere in the process of writing the according query? Or do you want us to do both, algorithm and query, for you? – Thorsten Kettner Jan 03 '18 at 09:11
  • And "age in year and month" means full years and months according to the day number in the month? So a person born 2016-10-31 would be one year and zero months on 2017-11-30 and one year and one month the day after (i.e. 2017-12-01)? – Thorsten Kettner Jan 03 '18 at 09:28
  • my underlying database is Sql server – Pooneh.T Jan 03 '18 at 09:34

1 Answers1

0

SELECT DATEDIFF(DAY,CAST ('20170921' AS DATE),CAST ('20180103' AS DATE) )

Aryan Sena
  • 170
  • 2
  • 2
  • 12