Dynamically created DATEDIFF function


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 2 of 2

Thread: Dynamically created DATEDIFF function

  1. #1
    Join Date
    Aug 2007
    Posts
    5

    Question Dynamically created DATEDIFF function

    Hi

    Does anyone know if I can dynamically create a DATEDIFF function within a query.

    Example:
    Code:
    SELECT * FROM myTable
    WHERE (DATEDIFF(intervalCode, lastExecution, GETDATE()) >= intervalNumber)
    As you can see, I filled up all the arguments with data from columns. The problem is that the first argument (underlined above) doesn't have a data type. Normally it should be written as a kind of a "keyword", like this:

    Code:
    SELECT * FROM myTable
    WHERE (DATEDIFF(yy, lastExecution, GETDATE()) >= intervalNumber)

  2. #2
    Join Date
    Aug 2007
    Posts
    1

    Wink

    use case syntax

    case when intervalCode = 'MM' then datediff(mm...)
    when intervalCode = 'YY' then datediff(YY..)

Similar Threads

  1. call function for button
    By angela_quests in forum VB Classic
    Replies: 2
    Last Post: 04-13-2007, 05:57 AM
  2. Getting a GUI to run
    By Eric in forum Java
    Replies: 4
    Last Post: 04-14-2006, 10:09 AM
  3. Search System Tray
    By MyPlague in forum .NET
    Replies: 2
    Last Post: 03-20-2006, 06:18 PM
  4. Replies: 0
    Last Post: 05-16-2001, 06:24 PM
  5. dynamically created xml element
    By J. Vatnaland in forum XML
    Replies: 0
    Last Post: 01-20-2001, 02:06 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center