Results 1 to 2 of 2

Thread: SQL Problem

  1. #1

    Thread Starter
    Addicted Member ZanM's Avatar
    Join Date
    Oct 1999
    Location
    The here and now.
    Posts
    191
    I have a sql string that calculates the number of day between two times...

    SELECT ClientData.Name, ClientData.Address, ClientData.CustomerType, ClientData.LastWork, ClientData.NextScheduled, ClientData.JobStatus, DateDiff("d",Now(),[clientdata].[nextscheduled]) AS Expr1
    FROM ClientData
    WHERE (((DatePart("m",[CLIENTDATA].[NEXTSCHEDULED])) Like DatePart("m",Now())) AND ((DatePart("yyyy",[CLIENTDATA].[NEXTSCHEDULED])) Like DatePart("yyyy",Now())))
    ORDER BY ClientData.Name;

    I need to modify it to format the number of days into years or months some how

    this is the SQL statement that is actually used (the above is used to difine fields for a report

    Dim nReport As New Report
    If txtYear.Text = " " Or txtYear.Text = "" Then
    MsgBox "Please enter the year you wish to Search....", , "User Error.."
    Exit Sub
    End If
    If Len(txtYear.Text) < 4 Then
    MsgBox "You must enter the full numerical date. I.E. 2001....", , "User Error..."
    Exit Sub
    End If
    Dim sMonth As String
    sMonth = Trim(Left(lstMonth.Text, 2))

    If CInt(sMonth) < 1 Or CInt(sMonth) > 12 Then
    Beep
    MsgBox "You must select a month from the list.", , "User Error..."
    Exit Sub
    End If

    ClientDataEnvir.Commands("MonthlyReport").CommandText = "SELECT ClientData.Name, ClientData.Address, ClientData.CustomerType, ClientData.LastWork, ClientData.NextScheduled, ClientData.JobStatus, DateDiff('d',Now(),[clientdata].[nextscheduled]) AS Expr1 From ClientData Where (((DatePart('m', [ClientData].[NEXTSCHEDULED])) Like " & "'" & sMonth & "'" & ") And ((DatePart('yyyy', [ClientData].[NEXTSCHEDULED])) Like " & "'" & txtYear.Text & "'" & "))ORDER BY ClientData.Name;"
    Set nReport.DataSource = ClientDataEnvir
    nReport.DataMember = "MonthlyReport"
    ClientDataEnvir.rsMonthlyReport.Close 'Makes sure you open a new data stream
    ' nReport.Refresh
    nReport.Show


    Magiaus
    Visual Basic 6.0 SP5
    Visual C++ 6.0 SP5


    The only sovereign you can allow to rule you is reason.

  2. #2

    Thread Starter
    Addicted Member ZanM's Avatar
    Join Date
    Oct 1999
    Location
    The here and now.
    Posts
    191

    nobdy....

    No ideas at all? I havn't had any ethier. I think my boss is going to have to take it or leave it....
    Magiaus
    Visual Basic 6.0 SP5
    Visual C++ 6.0 SP5


    The only sovereign you can allow to rule you is reason.

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