UNIX DATETIME format
Posted in 1992
Quoting Stuart Hemming... from David Snyder's message ... my copy got deleted } Anyone out there know of a way of converting a unix 4-byte date to } DATETIME format? } Not sure whether you want UNIX capabilities or ESQL or Informix. David gave an example for 4GL. in Unix Bourne Shell: dt=`date +'%m/%d/%y'` puts 09/25/92 into variable $dt dt=`date +'%H:%M'` puts 09:01 into variable $dt dt=`date +'%y%j'` puts 92269 into variable $dt Also you can place this information into a function.ec file and call from a perform screen to place the date and time on the screen. In tThis case we are only placing the year. (This may be crude, but we are teaching ourselves) { long seconds, time(); char usertime[4]; struct tm *timerec, *localtime(); seconds = time((long *) 0); timerec = localtime(&seconds); { /*if (timerec->tm_mon > 9) timerec->tm_year = timerec->tm_year + 1;*/ /* put in as an example of accessing the elements of the structure */ } sprintf(usertime, "%02d", timerec->tm_year); pf_putval(usertime, CCHARTYPE, "az"); } This was written for 2.10 SE and is working in 4.1. We haven't gotten in to writing 4GL yet and still use C-Functions alot in our perform screens. For information on the time.h header, see pages 255-6, Date & Time Functions, Second Edition "The C Programming Language", by Kernighan and Ritchie. Hope some of this helps. Cheryl Gross (903) 334-3518 Red River Army Depot Information Center Texarkana, TX