Search
 
SCRIPT & CODE EXAMPLE
 

SQL

postgresql calculate age from birthdate

SELECT EXTRACT(YEAR from AGE(NOW(), birth)) as "age", * FROM customers;
Comment

calculate age in sql postgresql

#THIS WORKS FOR POSTGRES and MYSQL
# You can use the AGE function. The AGE function requires two arguementS.
# AGE(late date, early date). The NOW() function returns the current timestamp.

AGE(NOW(), date_of_birth) AS age

#Since NOW() is a timestamp, the result will be like this:
# 45 years 2 months 15 days 21:43:05.378372
#You can then use this to extract the age.

LEFT(age, STRPOS(age,' ')) 
Comment

PREVIOUS NEXT
Code Example
Sql :: sql add year to date 
Sql :: Query the list of CITY names ending with vowels (a, e, i, o, u) from STATION. Your result cannot contain duplicates. Input Format The STATION table is described as follows: 
Sql :: sqlite alter table add column 
Sql :: how to increase size of column in sql 
Sql :: cast string to datetime mysql 
Sql :: oracle table size 
Sql :: postgres add not null to existing column 
Sql :: get current date in pyspark sql 
Sql :: find mysql version linux 
Sql :: mysql connectorj maven de 
Sql :: select users 
Sql :: sql several or 
Sql :: sql drop schema 
Sql :: delete database mysql 
Sql :: crontab every month 
Sql :: how to check last gather stats on table in oracle 
Sql :: restart mysql server ubuntu 
Sql :: insert column with default value in sql 
Sql :: how to check all scheduled jobs in oracle 
Sql :: oracle check table space 
Sql :: import sql file laravel cmd 
Sql :: create table if not exists sql 
Sql :: sql decrement value by 1 if not null or zero 
Sql :: oracle list invalid password logon denied 
Sql :: funzioni plsql 
Sql :: dao function to check if database contains value 
Sql :: query any digits record 
Sql :: postgresql select as and fwhwere by this field 
Sql :: apex ORA-20999 
Sql :: describe sql server 
ADD CONTENT
Topic
Content
Source link
Name
8+6 =