Here's the UDF that I use.  It takes a datetime object and an optional
mask.  If the mask is omitted, it formats the datetime based on it's
age (just time for today, monthname and day for this year, m/d/yy for
previous years).  If the mask is provided and is the string "xml", it
will format it as an XML date (such as for using in RSS feeds).  If
the mask is provided and is not "xml", it will be passed verbatim to
the java.text.SimpleDateFormat class, which defines rules for
formatting datatime objects.  The "xml" format uses the behaviour (via
recursion), so you can get a basic idea of how it works.  Note that
the masks are case sensitive.

cheers,
barneyb

MIDNIGHT = createDate(year(now()), month(now()), day(now()));
NEWYEARS = createDate(year(now()), 1, 1);
function dateTimeFormat(d/*, mask*/) {
        var sdf = "";
        var offset = "";
        if (arrayLen(arguments) GT 1) {
                switch (arguments[2]) {
                        case "xml":
                                offset = -1 * getTimeZoneInfo().utcTotalOffset;
                                return dateTimeFormat(d,
"yyyy-MM-dd'T'HH:mm:ss")
                                        & numberFormat(int(offset /
3600), "+00")
                                        & ":"
                                        & numberFormat(int(offset /
60) MOD 60, "00");
                        default:
                                sdf = createObject("java",
"java.text.SimpleDateFormat").init(arguments[2]);
                                return sdf.format(d);
                }
        } else if (d GTE MIDNIGHT) {
                return lCase(timeFormat(d, "h:mm tt"));
        } else if (d GT NEWYEARS) {
                return dateFormat(d, "mmm d");
        } else {
                return dateFormat(d, "m/d/yy");
        }
}


On 7/27/05, Ian Skinner <[EMAIL PROTECTED]> wrote:
> Because dateformat only formats DATES not TIMES.  So the MM in your time 
> portion stands for the two digit MONTH number, not MINUTES; so that '07' is 
> for July.
> 
> It's a bit annoying, but you need to do #dateFormat(...)##timeFormat(...)# to 
> get what you want.  I would not be surprised if there is not a UDF out there 
> that combines this, but I have not been annoyed enough to look for it yet.
> 

-- 
Barney Boisvert
[EMAIL PROTECTED]
360.319.6145
http://www.barneyb.com/

Got Gmail? I have 50 invites.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Logware (www.logware.us): a new and convenient web-based time tracking 
application. Start tracking and documenting hours spent on a project or with a 
client with Logware today. Try it for free with a 15 day trial account.
http://www.houseoffusion.com/banners/view.cfm?bannerid=67

Message: http://www.houseoffusion.com/lists.cfm/link=i:4:213018
Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4
Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
Donations & Support: http://www.houseoffusion.com/tiny.cfm/54

Reply via email to