Bad Date-Time Format

Posted on 2007-07-27
Last Modified: 2008-01-09

I need help calculating AVERAGE TIME. I have a field that holds a CALL_DURATION of a telephone call in this format:


When I try to use this formula I get the error:   BAD DATE-TIME FORMAT STRING

(hour(datetime({View_smdrdata_Phone_System.CallDuration})) * 60 * 60 ) +
(minute(datetime({View_smdrdata_Phone_System.CallDuration})) * 60)
+ (second(datetime({View_smdrdata_Phone_System.CallDuration})))
) /60

This is the portion that is CR highlights as being a problem:


I've tried different things...but I can't seem to get it....your help is appreciated.

Question by:MIKE
    LVL 20

    Accepted Solution

    Your values are not standard date-time values, they are totals reflected as min:ss.

    In other words, datetime expects a format similar to mm/dd/yy hr:mi:ss, which is not what you have. You have only a total of minutes on the left side and the seconds on the right side, delimited by the colon.

    You'll need to do some simple piecing of the field. If you want to average the call duration, lose the datetime function and convert them into seconds similar to the following:

    (Left({View_smdrdata_Phone_System.CallDuration}, InStr({View_smdrdata_Phone_System.CallDuration}, ":") - 1) * 60) + Mid({View_smdrdata_Phone_System.CallDuration}, InStr({View_smdrdata_Phone_System.CallDuration}, ":") + 1)

    You may have to tweak this proposed solution a bit, but hope it helps.
    LVL 20

    Expert Comment

    Of course, you may need to reverse the average back into the same format as the call duration. If your average ends up being only a value reflected in seconds, that could be done in the Display XSS with the following:

    (CurrentFieldValue \ 60) & ":" & (CurrentFieldValue Mode 60)
    LVL 17

    Author Comment


    A number or currency amount is required...

    I'll keep adjusting the type and see if I can get it to work...
    LVL 5

    Assisted Solution

    Just a little cleaner solution

    tonumber(split({View_smdrdata_Phone_System.CallDuration},":")[1])*60 + tonumber(split({View_smdrdata_Phone_System.CallDuration},":")[2])


    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Highfive Gives IT Their Time Back

    Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

    I hate sub reports and always consider them the last resort in any reporting solution.  The negative effect on performance and maintainability is just not worth the easy ride they give the report writer.  Nine times out of ten reporting requirements…
    Hot fix for .Net Crystal Reports 10.2.3600.0 to fix problems with sub reports running on 64 bit operating systems ISSUE: Reports which contain subreports fail with error "Missing Parameter Value" DEPLOYMENT SERVER OS: Windows 2008 with 64 bi…
    how to add IIS SMTP to handle application/Scanner relays into office 365.
    Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

    779 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    14 Experts available now in Live!

    Get 1:1 Help Now