Thread: Loop problem

    #1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2012
    Posts
    1
    Rep Power
    0

    Loop problem


    I want to create a new field with either yes or no depending on if the RowNum 1 is a continuation from RowNum 2 for each staff member, this can be identified by the Last_Day of RowNum 2 being the day before the First_Day of RowNum 1

    Example
    Staff_Number F_Date L_date RowNum Cont
    001234 01/02/12 29/02/12 1 Y
    001234 01/01/12 31/01/12 2
  2. #2
  3. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2012
    Posts
    3
    Rep Power
    0
    Suggestion :

    -- @mydate = F_Date (F_Date can be any day of the month)
    DECLARE @mydate DATETIME
    SELECT @mydate = '01/01/2012'

    SELECT CONVERT(VARCHAR(25),DATEADD(dd,-(DAY(@mydate)-1),@mydate),101) AS Date_Value,
    N'The first date of the current month' AS Date_Type
    UNION ALL
    SELECT CONVERT(VARCHAR(25),DATEADD(dd,-(DAY(DATEADD(mm,1,@mydate))),DATEADD(mm,1,@mydate)),101) ,
    N'The last date of the current month'

IMN logo majestic logo threadwatch logo seochat tools logo