Re: formating a DATETIME into a string
Posted in 1997
This is a multi-part message in MIME format. --------------A7C30BD4A29 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Steen N. Hansen wrote: > > how do i make a format on a datetime, in a way like formating a date type: > > x char (30) > > let x = today using "dd.mm.yyyy" > > is there some special function ? or do i have to build one my self: I have a NewEra class that does this sort or thing. The conversion to 4GL would be minor. Header and File are attached. It's new and not throughly tested, so please report any bugs. And of course, there's no warranty. Usage comments are in the .4gl file. //////////////// ======================================================= ////////// // Dennis J. Pimple Informix Software, Inc. ////// / /// Principal Consultant 5299 DTC Blvd Suite 740 ///// // //// dennisp@informix.com Englewood CO 80111 //// // ///// /// // ////// recept: 303-850-0210 // // /////// direct: 303-740-5611 Opinions expressed are mine, / /////////// fax: 303-843-6408 and do not necessarily //////////////// http://www.informix.com reflect those of my employer --------------A7C30BD4A29 Content-Type: text/plain; charset=us-ascii; name="cdatetf.4gh" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="cdatetf.4gh" ############################################################################### ############################################################################### ------------------------------------------------------------------------------- -- -- Module Name : cdatetf.4gh -- Description : CDateTime Format object -- Version : 0.1 -- Date Created : 10/14/1997 -- Date Last Edited : 10/14/1997 -- -- Author : Dennis J. Pimple (dennisp@informix.com) -- Informix Software Inc. -- -- -- Date Revisions, Corrections, Bug Fixes, etc. -- ---------- --------------------------------------------------------------- -- ------------------------------------------------------------------------------- ############################################################################### ############################################################################### ------------------------------------------------------------------------- ------------------------------------------------------------------------- -- -- CLASS NAME: CDateTimeFormat -- NOTES: CDateTimeFormat formats DATETIME values in various ways. -- ------------------------------------------------------------------------- ------------------------------------------------------------------------- CLASS CDateTimeFormat -- -- member variables -- -- -- member functions -- PUBLIC FUNCTION CDateTimeFormat() -- -- PUBLIC FUNCTION formatDatetime( theDatetime DATETIME YEAR TO FRACTION(5), format CHAR(*) ) RETURNING CHAR(*) -- PRIVATE FUNCTION DTToFormat( theDatetime DATETIME YEAR TO FRACTION(5), format CHAR(*) ) RETURNING CHAR(*) -- PRIVATE FUNCTION DateToFormat( theDate DATE, format CHAR(*) ) RETURNING CHAR(*) END CLASS --------------A7C30BD4A29 Content-Type: text/plain; charset=us-ascii; name="cdatetf.4gl" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="cdatetf.4gl" ################################################################################ ################################################################################ -------------------------------------------------------------------------------- -- -- Module Name : CDATEF.4GL -- Program Name : utillib.dll -- Version : 1.0 -- Date Created : 10/14/1997 -- Date Last Edited : 10/14/1997 -- -- Author : Dennis Pimple (dennisp@informix.com) -- Informix Software Inc. -- -- Date Revisions, Corrections, Bug Fixes, etc. -- ---------- ------------------------------------------------------------------ -- -------------------------------------------------------------------------------- ################################################################################ ################################################################################ -------------------------------------------------------------------------------- -- Informix System Header Files -------------------------------------------------------------------------------- -------------------------------------------------------------------------------- -- Project Specific Header Files -------------------------------------------------------------------------------- INCLUDE "cdatetf.4gh" -------------------------------------------------------------------------------- -------------------------------------------------------------------------------- -- -- FUNCTION/OBJECT NAME : CDatetimeFormat::CDatetimeFormat -- DESCRIPTION : Class Constructor -- ARGUMENTS REQUIRED : NONE -- RETURN VALUES : NONE -- EVENTS RAISED : NONE -- NOTES: -- -------------------------------------------------------------------------------- -------------------------------------------------------------------------------- FUNCTION CDatetimeFormat::CDatetimeFormat() END FUNCTION # CDatetimeFormat::CDatetimeFormat() -------------------------------------------------------------------------------- -------------------------------------------------------------------------------- -- -- FUNCTION/OBJECT NAME : CDatetimeFormat::formatDatetime -- DESCRIPTION : Format the passed DATETIME -- according to the passed string -- ARGUMENTS REQUIRED : A DATETIME (YEAR to any scale), format string -- RETURN VALUES : CHAR(*) with the formatted value -- EVENTS RAISED : NONE -- NOTES : any of the following will be interpreted. -- Symbols for character strings will follow the shift pattern given -- examples are for Monday, February 3, 1997 11:45:59.00000 pm -- -- DATE FORMATS -- wd Weekday 1 -- da/Da/DA 2-char day mo/Mo/MO -- day/Day/DAY 3-char day mon/Mon/MON -- dayf/Dayf/DAYF full day monday/Monday/MONDAY -- d 1-digit day 3 (1-31) -- dd day of month 03 (01-31) -- mo/Mo/MO 3-char month feb/Feb/FEB -- mon/Mon/MON full month february/February/FEBRUARY -- m 1-digit month 2 (1-12) -- mm numeric month 02 (01-12) -- y 1-digit year 97 (1-99) -- yy 2-digit year 97 (01-99) -- yyyy 4-digit year 1997 -- TIME FORMATS -- h am/pm 1-digit hour 11 (1-12, 12:00 am is midnight) -- hr am/pm hour