Results 1 to 7 of 7

Thread: Datediff question (RESOLVED)

  1. #1

    Thread Starter
    Hyperactive Member cajsoft's Avatar
    Join Date
    Aug 2000
    Location
    Glasgow, Scotland
    Posts
    295

    Datediff question (RESOLVED)

    Hi,
    I am writing a small helpdesk utility and wish to report the number of calls resolved within seven days. The code below works great but I'd like to be able calculate the first day as monday. e.g, show all calls resolved from last monday

    anyone help me please?


    Code:
    if DateDiff("d",ors.fields("ResolvedDate"),now)<=7 then
    	    resolvedin  = resolvedin + 1
    end if
    Last edited by cajsoft; Jul 15th, 2004 at 03:51 AM.
    Craig Johnstone, MCP,CNA

    VB 6,SQL,Lotus Notes,Crystal Reports 7,8

    http://www.cajsoft.co.uk/downloads.htm

  2. #2
    Frenzied Member dj4uk's Avatar
    Join Date
    Aug 2002
    Location
    Birmingham, UK Lobotomies: 3
    Posts
    1,131
    Just to clarify...

    If you wanted to view calls resolved for this week that would cover Monday 12th and Tuesday 13th.

    If you wanted last weeks numbers that would be between Monday 5th and Sunday 11th.

    Does this sound right?

    DJ

  3. #3

    Thread Starter
    Hyperactive Member cajsoft's Avatar
    Join Date
    Aug 2000
    Location
    Glasgow, Scotland
    Posts
    295
    Yes Thats correct.. each week I want to show calls resolved from previous monday through to sunday night.
    Craig Johnstone, MCP,CNA

    VB 6,SQL,Lotus Notes,Crystal Reports 7,8

    http://www.cajsoft.co.uk/downloads.htm

  4. #4
    Fanatic Member davebat's Avatar
    Join Date
    Dec 2002
    Posts
    727
    Try:

    Code:
    if DateDiff("d",ors.fields("ResolvedDate"),now,2)<=7 then
    	    resolvedin  = resolvedin + 1
    end if
    By adding the 2 into the function you are telling it the first day of the week is a Monday, is this what you meant?

  5. #5

    Thread Starter
    Hyperactive Member cajsoft's Avatar
    Join Date
    Aug 2000
    Location
    Glasgow, Scotland
    Posts
    295
    Originally posted by davebat
    Try:

    Code:
    if DateDiff("d",ors.fields("ResolvedDate"),now,2)<=7 then
    	    resolvedin  = resolvedin + 1
    end if
    By adding the 2 into the function you are telling it the first day of the week is a Monday, is this what you meant?
    It's still showing more calls resolved than there should be. Only 7 calls were resolved since monday, but it's showing all calls from 7 days ago.?
    Craig Johnstone, MCP,CNA

    VB 6,SQL,Lotus Notes,Crystal Reports 7,8

    http://www.cajsoft.co.uk/downloads.htm

  6. #6
    Fanatic Member davebat's Avatar
    Join Date
    Dec 2002
    Posts
    727
    try this then, it will look back to the p[ast seven days as you have hard coded this number in. Use a variable instead.

    Code:
    <%
    V_DAY = weekday(date(),2)
    
    if DateDiff("d",ors.fields("ResolvedDate"),now,2)<= V_DAY then
    	    resolvedin  = resolvedin + 1
    end if
    %>

    I think the easiest way to do this would be within the sql, so that it only pulls out records that fallw ithin the two dates. If you need help doing this let me know.

  7. #7

    Thread Starter
    Hyperactive Member cajsoft's Avatar
    Join Date
    Aug 2000
    Location
    Glasgow, Scotland
    Posts
    295
    Cheers mate. Thats whay I was looking for.
    Craig Johnstone, MCP,CNA

    VB 6,SQL,Lotus Notes,Crystal Reports 7,8

    http://www.cajsoft.co.uk/downloads.htm

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width