Sponsored Content
Special Forums UNIX and Linux Applications Calculating age from date of birth Post 302461936 by JerryHone on Tuesday 12th of October 2010 06:40:15 PM
Old 10-12-2010
Thanks jgt...

This is what I've ended up with...
Code:
SELECT 
    date_format(DOB, '%d/%m/%Y') DOB , 
    convert((date_format(now(),'%Y%m%d') - date_format(DOB, '%Y%m%d'))/10000, unsigned) Age   
FROM
    table

Now, if only I understood why that works! What's the difference between subtracting formatted dates and unformatted dates? And why 10000? Smilie
 

9 More Discussions You Might Find Interesting

1. What is on Your Mind?

What is your age?

What is your age? (15 Replies)
Discussion started by: royal
15 Replies

2. Shell Programming and Scripting

file age

How can I count the age of the file (e.g. in minutes)? (4 Replies)
Discussion started by: jarmo.leppanen
4 Replies

3. Shell Programming and Scripting

Store date-of-birth as "1#7#0#2#" in file

Hello, My input files are having header/body/footer. The first three digits finds whether the data is header/body/footer. For example, 010AAAAA 20100507 234KB BBBBBBBBBB_20100506.DAT 020CCCCC DDDDDDDDD 373983983 19750426 456.90 ... (1 Reply)
Discussion started by: nvkuriseti
1 Replies

4. Shell Programming and Scripting

Calculating using date

I need to help to calculating using date in a script. One application is licensed by date, some month at a time. I can read the date from system and get an output like this: echo $status 6A34 System4 01.01.11-31.01.11 My goal is to use license date 31.01.11 and subtract todays date... (7 Replies)
Discussion started by: Jotne
7 Replies

5. UNIX and Linux Applications

sqlite: calculating with dates - compare current date minus 6 months with stored record

Hi I have a table with name, date in format DD.MM.YYYY. I need to something like this (I try to explain in pseudo code) if SYSDATE (current date) minus 6 months > $expiry date print OK else print NOK with $name and $expiry date I know this is possible with Oracle. How to do this... (0 Replies)
Discussion started by: slashdotweenie
0 Replies

6. Shell Programming and Scripting

Calculating 7 days ago date for the given Argument

Hi I have shell script and I am facing the below issue to integrate the date calculation to the the script. If I give the $1 as the date(20110701) then I need to get the 7 days ago date for the same format.(20110624). At first I thought its a simple one to handle and I did a search in the... (10 Replies)
Discussion started by: filter
10 Replies

7. Shell Programming and Scripting

Calculating expiry date using date,sed,grep

Hi, I would greatly appreciate it if someone can help me with my problem. I have a crawler which collects spam URLs everyday & this data needs to be published in a blacklist. Here's the catch: The "Time To Live" (TTL) for each URL is 3 months (or whatever for that matter). If i see the... (5 Replies)
Discussion started by: r4v3n
5 Replies

8. Shell Programming and Scripting

Calculating the epoch time from standard time using awk and calculating the duration

Hi All, I have the following time stamp data in 2 columns Date TimeStamp(also with milliseconds) 05/23/2012 08:30:11.250 05/23/2012 08:30:15.500 05/23/2012 08:31.15.500 . . etc From this data I need the following output. 0.00( row1-row1 in seconds) 04.25( row2-row1 in... (5 Replies)
Discussion started by: ks_reddy
5 Replies

9. UNIX for Dummies Questions & Answers

Age of file

Hi All.. Is there any easy way to find out how many days older is file? for ex. fileA 20 days fileB 10 days I am currently on AIX, and there is no STAT command available in this environment. What are my options? Thanks Abhijeet R (1 Reply)
Discussion started by: freakabhi
1 Replies
DATETIMEINTERFACE.FORMAT(3)						 1					       DATETIMEINTERFACE.FORMAT(3)

DateTime::format - Returns date formatted according to given format

       Object oriented style

SYNOPSIS
public string DateTime::format (string $format) DESCRIPTION
string DateTimeImmutable::format (string $format) string DateTimeInterface::format (string $format) Procedural style string date_format (DateTimeInterface $object, string $format) Returns date formatted according to given format. PARAMETERS
o $object -Procedural style only: A DateTime object returned by date_create(3) o $format - Format accepted by date(3). RETURN VALUES
Returns the formatted date string on success or FALSE on failure. EXAMPLES
Example #1 DateTimeInterface.format(3) example Object oriented style <?php $date = new DateTime('2000-01-01'); echo $date->format('Y-m-d H:i:s'); ?> Procedural style <?php $date = date_create('2000-01-01'); echo date_format($date, 'Y-m-d H:i:s'); ?> The above example will output: 2000-01-01 00:00:00 NOTES
This method does not use locales. All output is in English. SEE ALSO
date(3). PHP Documentation Group DATETIMEINTERFACE.FORMAT(3)
All times are GMT -4. The time now is 10:41 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy