Adding a minimum field to an already long sql statement

  • I want to change the below statement to include a minimum field

    on the between range for the timestamp field

    This is a timestamp field MM/DD/YYYY hh:mm:ss AM is the format

    So I want only to use todays date and set it so that it wont pull data from before 14:29:50 of the current day, there will be data in the database from before that time but I dont want to bring it through

    How can I do put that in to the current statement

    Thanks

    Jon

    rsRecordset15.Open "select ESASKSIZE AS ESASKSIZE,ESBIDSIZE AS ESBIDSIZE from DBO.DEMANDSPREAD WITH (NOLOCK) WHERE ESASKSIZE > '' AND ESBIDSIZE > '' AND TIMESTAMP BETWEEN DATEADD(mi, -40, " & "'" & DSMAXTS & "'" & ") AND " & "DATEADD(ss, -1," & "'" & DSMAXTS & "'" & " )ORDER BY TIMESTAMP ASC", gcnConnect, adOpenKeyset, adLockReadOnly

    If Not rsRecordset15.EOF Then

    cell1 = rsRecordset15.RecordCount

    Call Sheet4.Range("A2").CopyFromRecordset(rsRecordset15) 'ESASKSIZE

    End If

    rsRecordset15.Close

    Sheet6.Range("C3") = Sheet4.Cells(cell1 + 1, 11)

    Sheet6.Range("D3") = Sheet4.Cells(cell1 + 1, 12)

    Sheet6.Range("E3") = Sheet4.Cells(cell1 + 1, 13)

    Sheet6.Range("C4") = Sheet4.Cells(cell1 + 1, 14)

    Sheet6.Range("D4") = Sheet4.Cells(cell1 + 1, 15)

    Sheet6.Range("E4") = Sheet4.Cells(cell1 + 1, 16)

    Sheet6.Range("C5") = Sheet4.Cells(cell1 + 1, 5)

    Sheet6.Range("C6") = Sheet4.Cells(cell1 + 1, 8)

  • jon pill (6/11/2008)


    So I want only to use todays date and set it so that it wont pull data from before 14:29:50 of the current day, there will be data in the database from before that time but I dont want to bring it through

    Put this in your where clause: [DATETIME FIELD] > DATEADD(dd,-1,CAST(CONVERT(VARCHAR(20),GETDATE(),101)+' 14:29:50' AS DATETIME))

Viewing 2 posts - 1 through 1 (of 1 total)

You must be logged in to reply to this topic. Login to reply