Kesavan Muthuvel's Personal Home Page

Index | Bookmarks | I'm supporting | More info? | Royal Thunderbird! | Maemo N900 | Nexus 4 (Android + more ) | KODI [aka] XBMC | My Public Key (GPG) | My Sign | Travel Photos | Blog
Thanks to.. | Open Materials | interview qns | scripts to look | RegEx me! | Web Dev tips | eBooks Collection
Looking for a girl A day - a cartoon Shameless self promo Generate random values

Scripts I like

Here are some scripts which are useful for preparations in PHP / MySQL .Please run these.Don't just read this. Thanks to highlight_file() of PHP.

PHP Info | echo Vs print | PHP MCRYPT | PHP FUNCTION(?) | PHP __wakeup() | PHP Date Calc | PHP Multi file attach MAIL | MySQL Date Calc | PHP OOPs | jQuery

CREATE FUNCTION getDateDifferenceString(date1 DATE, date2 DATE) 
RETURNS VARCHAR(30)  
RETURN CONCAT(    
@years := TIMESTAMPDIFF(YEAR, date1, date2),  
    IF (@years = 1, ' year, ', ' years, '),    
@months := TIMESTAMPDIFF(MONTH, DATE_ADD(date1, INTERVAL @years YEAR), date2),  
    IF (@months = 1, ' month, ', ' months, '),    
@days := TIMESTAMPDIFF(DAY, DATE_ADD(date1, INTERVAL @years * 12 + @months MONTH), date2),  
    IF (@days = 1, ' day', ' days')  
);

/* USAGE 
mysql> SELECT getDateDifferenceString('2006-03-01',NOW()) MyExperience;
+----------------------------+
| MyExperience               |
+----------------------------+
| 5 years, 5 months, 23 days |
+----------------------------+
1 row in set, 1 warning (0.00 sec)
*/


Return to Kesavan Muthuvel's home page.

Please send comments on these web pages to hi@kesavan.info (or)  Feedback here

CopyLeft (Ͻ) 2008 - 2015 Kesavan Muthuvel More on CopyLeft

I Don't Love FaceBook