Results 1 to 3 of 3
  1. #1
    Join Date
    Jan 2012
    Posts
    3

    Red face Unanswered: Updating Date in SQL Query (Excel Connections OLE DB Query)

    Hello,

    I am running a query that returns transactions that were done at a given point.

    For this, I am using the"connections" part of Excel.

    I have created a workbook connection

    Connection type : OLE DB Quert

    Command Type: SQL

    Command Text:

    Select
    t.SP_ID AS Salesperson
    ,sum(CASE t.Transaction_Date WHEN '01/05/2012' THEN (abs(t.Transaction_Units) * t.Transaction_Price

    etc

    It runs finds and returns my data into a table in Excel.

    However, I need to manually update the relevant date in the Command Text.

    Is there a way that the connection automatically updates the date. as indicated in a cell in Excel, or maybe t-1 given that the file updates automatically every time I open?

    MAny thanks

  2. #2
    Join Date
    Jan 2007
    Location
    UK
    Posts
    11,434
    Provided Answers: 10
    You can obtain today's date in SQL using the GetDate() function.

    Code:
    SELECT GetDate() As todays_date_and_time
         , DateAdd(dd, DateDiff(dd, 0, GetDate()), 0) As todays_date_no_time
    George
    Home | Blog

  3. #3
    Join Date
    Jun 2003
    Location
    Ohio
    Posts
    12,592
    Provided Answers: 1
    No.
    You should not be trying to update database date from Excel, anyway. Excel is acceptable for viewing data, but it is not appropriate as a user-interface for transaction processing.
    If it's not practically useful, then it's practically useless.

    blindman
    www.chess.com: "sqlblindman"
    www.LobsterShot.blogspot.com

Tags for this Thread

Posting Permissions

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