Click here to monitor SSC

substring function

Last post 04-27-2009, 4:38 PM by Arles. 1 replies.
Sort Posts: Previous Next
  •  04-24-2009, 9:24 AM Post number 73244

    • tcstl is not online. Last active: 03-15-2011, 2:45 PM tcstl
    • Top 50 Contributor
    • Joined on 05-02-2007
    • Blue Gene

    substring function

    I have a field value which will have the following

    2 days

    1 week

    1 month

    1 month 2 days

    I want to create a trigger on this table to interpret this value and create a date value based upon getdate() + the correct amount of days.  ( I am standardizing that a month is 30 days)

     

     

  •  04-27-2009, 4:38 PM Post number 73277 in reply to post number 73244

    • Arles is not online. Last active: 02-23-2011, 7:26 AM Arles
    • Top 25 Contributor
    • Joined on 10-20-2008
    • Nashville, TN
    • Celeron 450

    Re: substring function

    Copy-past the following statement in your Query Analyzer and see if this is what you need:

    SELECT DATEADD( DD, 2, GETDATE() )     -- 2 days from today's date

    SELECT DATEADD( WK, 1, GETDATE() )   -- 1 week from today's date

    SELECT DATEADD( DD, 30, GETDATE() )  -- 30 days/1 month from today's date; 
                                                                                  
    -- if you need next month then use DATEADD( MM, 1, GETDATE() )

    SELECT DATEADD( DD, 32, GETDATE() )   -- 30 days/1 month & 2 days from today's date; 
                                                                                    -- if you need "next month plus 2" days then use 
                                                                                    --   DATEADD( DD, 2, DATEADD( MM, 1, GETDATE() ) )


    If this is what you need then simply replace the “SELECT” statement with the variable/field assignment operation in your trigger.

     

View as RSS news feed in XML