Best way to derive a "week ending" date using the Derived Column Transformations

Hi, I have an interesting challenge. I am working on creating a BI DB that contains timesheet data. The data contains a column representing the date "worked"  ([Date]. Nearly all output reporting is based on a timesheeting week that end on
a Wednesday. My thinking has been to create a derived column "WE" (week ending) that represents the entries of the preceding 6 days.
(Originally I entertained deriving this value view SQL view - however we are talking about a DB that is is a substantial DB (excess of 100M timesheet bookings) and an index on the WE field is warranted) so decided a derived WE column was best approach.
The Date field is represented from a SAP format (German long dated format) - however I cannot use the convert option ;( in the TE.
The Date field is derived via: (DT_DATE)(SUBSTRING([Date      ],7,4) + "-" + SUBSTRING([Date      ],4,2) + "-" + SUBSTRING([Date      ],1,2))
I would welcome some recommendation on how to best derive a WE column. (The DT_DATE format is not susceptible to a /7, mod7 operation).
Thanks in advance,
/L

Try this solution :
http://stackoverflow.com/questions/1803987/how-do-i-exclude-weekend-days-in-a-sql-server-query

Similar Messages

  • Best way to go about having two people use the same form?

    Hi guys,
    Relativly new to livecycle and I need some help.
    I've been asked to make a form that 2 different people will have access too, what I need to do is as followed:
    Person 1
    Only has access to the first 5 pages and is able to fill out the form
    Person 2
    Has access to the WHOLE document and can see what PERSON 1 has entered.
    Can this be done with two different versions of the document, or will it have to be all as one?
    Regards

    Well I have done it before by using a button which the second person clicks and this brings up a messagebox which asks for a password. If the password is entered correctly the rest of the form (which is originally set to hidden) will become visible. The code in the click event of the button is something like (in formcalc):
    var correctpassword = xfa.host.response("Password:","For office use only","",1)
    if (correctpassword == "whateverYouWantYourPasswordToBe") then
        restOfForm.presence = "visible"
        $.presence = "hidden"
    else xfa.host.messageBox("You have entered the wrong password","For office use only",1)
    endif

  • Week end Date Query...

    Hi
    I want Week end date for the following Condition.
    1.If month start date from sunday or monday mean week end should be Current Sat date other wise i want next saturday as first week end date.
    For Eg.. AUG 2006
    O/P should be
    12-aug-2006
    19-aug-2006
    26-aug-2006
    31-aug-2006
    2.If Months Starts from sun or monday mean i don't want last sat in the list
    For Eg.. JAN 2006
    07-jan-2006
    14-jan-2006
    21-jan-2006
    31-jan-2006
    Hlp me
    Regards
    Manikandan

    Hi jeneesh,
    Thanks for giving the query ... For the Below Same query i need
    1.If the first week of the month is Sunday Or Monday then week1 ends on the first saturday else week1 ends on the second saturday of the month.
    2. Week 2 ends on the next Saturday ( next to the one identified above)
    3. Week3 ends on the next Saturday ( next to the one indentified in step 2)
    4. Week4 ends on the last day of the Month.
    For Eg of JAN-2006, i don't want to display last sat.. insteed of i want to display last day of the month ,
    SELECT NEXT_DAY(TO_DATE('JAN-2006','mon-yyyy')+5+(N-1)*7,'SATURDAY') col1
    FROM (SELECT ROWNUM N
    FROM DUAL
    CONNECT BY LEVEL <= 4)
    WHERE NEXT_DAY(TO_DATE('JAN-2006','mon-yyyy')+5+(N-1)*7,'SATURDAY') <= LAST_DAY(TO_DATE('JAN-2006','mon-yyyy'))

  • Getting the start  and end dates of the week

    Hi,
    I was stuck with a problem in getting the start date and end date of the week,i know the month ,week and year also,with these three values how can i get the start and end dates of a week.please help me
    Thanks

    There is no simple way. It has to be a math calculation.
    There are several ways you can get the dates. First you have to know what day is January 1st and what day is december 31st for a particular year. Second you have to check whether the given year is a leap year or not. Based on the abvove information you should be able to find out what day is a particular date.
    Hope this helps to get you started.
    - Venkat Dhurjati.

  • Week End Date calculates dates in table issues

    Greetings All,
    I'm working on a LiveCycle Designer ES4 document that has a Week Ending Date MM-DD-YYYY (which need to always be a Saturday) selected in a subform.
    I need this Week End Date to then calculate and display the selected Saturday and the previous days in a seperate subform with a table. The days need to display in seperate columns below the header.
    This is what I have so far:
      TopmostSubform.Page1.Requestor.WeekEndDate::exit - (FormCalc, client)
    var endDate = Date2Num($,"MM-DD-YYYY")
    var dayOfWeek = Num2Date(endDate, "E")
    if (dayOfWeek <> 7) then
       xfa.host.messageBox("Ending date must be a Saturday")
       $ = null
       xfa.host.setFocus("$")
    endif
    Page1.#subform[1].InputTable.Row1[0].Date7 = Num2Date(endDate - 0, "DD")
    Page1.#subform[1].InputTable.Row1[0].Date6 = Num2Date(endDate - 1, "DD")
    Page1.#subform[1].InputTable.Row1[0].Date5 = Num2Date(endDate - 2, "DD")
    Page1.#subform[1].InputTable.Row1[0].Date4 = Num2Date(endDate - 3, "DD")
    Page1.#subform[1].InputTable.Row1[0].Date3 = Num2Date(endDate - 4, "DD")
    Page1.#subform[1].InputTable.Row1[0].Date2 = Num2Date(endDate - 5, "DD")
    Page1.#subform[1].InputTable.Row1[0].Date1 = Num2Date(endDate - 6, "DD")
    However I keep getting an error on the WeekEndDate when selecting a Saturday.
    Does anyone have any idea what I'm doing wrong?
    Thank you for any help!
    -Michelle

    Well, I never got an answer from the forum here, but to help out others - here is what I did:
    This was all done in FormCalc.
    The object WeekEndDate Date/Time Field has a set pattern date{MM/DD/YYYY} in the Object Field Pattern in LiveCycle.
    BUT, the Scripting required the pattern to be YYYY-MM-DD
    Why? I have no flipping clue. It won't work any other way for me.
    Also this item requires a Saturday Date to be chosen. Days of the week are designated by numbers (Sunday = 1, Monday = 2, etc.)
    The line <>7 means that if the day is not Saturday (7) then the error message "Ending date must be a Saturday" will appear.
    This is the Exit event Script:
    TopmostSubform.Page1.Requestor.WeekEndDate::exit- (FormCalc, client)
    var endDate = Date2Num($,"YYYY-MM-DD")
    var dayOfWeek = Num2Date(endDate, "E")
    if (dayOfWeek <> 7) then
         xfa.host.messageBox("Ending date must be a Saturday")
         $ = null
         xfa.host.setFocus("$")
    endif
    The individual Date cells are set to a Date/Time Field with no pattern set in the Object Field Pattern in LiveCycle.
    The coding below designates a MM/DD pattern.
    Each individual field has it's own scripting, with the appropriate minus calculation  - #
    This is the Calculate script for the Sunday cell:
    TopmostSubform.Page1.#subform[1].InputTable.Row1[0].Date1::calculate - (FormCalc, client)
    var dateNum = date2num(TopmostSubform.Page1.Requestor.WeekEndDate.formattedValue,"MM/DD/YYYY") - 6
    $.rawValue = num2date(dateNum,"MM/DD")
    And the Saturday cell, that needed to display the Saturday End Date has the following Script, with NO minus number:
    TopmostSubform.Page1.#subform[1].InputTable.Row1[0].Date7::calculate - (FormCalc, client)
    var dateNum = date2num(TopmostSubform.Page1.Requestor.WeekEndDate.formattedValue,"MM/DD/YYYY")
    $.rawValue = num2date(dateNum,"MM/DD")
    Why did I include this all here?
    Because this whole project has been gawd-awful, and hopefully these insights can help another struggle forms designer understand the FormCalc scripting used.
    -M

  • What is the best way to move all of my data from an iPad 4 to an air?

    Santa brought an iPad Air and I need to transfer my data and apps from the old iPad I have had.  Help on the best way to do this since I played with the new machine yesterday and some of the things transfered but not all.
    Thanks!

    How to Transfer Everything from an Old iPad to New iPad
    http://osxdaily.com/2012/03/16/transfer-old-ipad-to-new-ipad/
    iOS: Transferring information from your current iPhone, iPad, or iPod touch to a new device
    http://support.apple.com/kb/HT2109
    Moving Content to a New iPad
    http://tinyurl.com/qzk2a26
    Transferring your prepaid cellular data account depends on your carrier. AT&T lets you move it yourself when you go to Cellular Data in Settings and log into your account with your previous AT&T user name and password. For iPads with Sprint service, you can set up an account on the new iPad and contact Sprint Customer Care (888-211-4727 and go through the menus) to deactivate the old plan and get credit for unused service. For Verizon, call the company’s customer service number for mobile broadband support (800-786-8419) and ask to have your account transferred.
     Cheers, Tom

  • Is there a way to show the end dates of the previous month stand out?

    is there a way to show the end dates of the previous month in bold or make it stand out? so 30,31 and 1st of this month don't all look the same? For example the 30,31st get a regular text since they are a part of the the last month and this month gets bold dates? Its hard to read the dates anyways.

    Pics and more
    I may receive some form of compensation, financial or otherwise, from my recommendation or link.
    5:05 PM Sunday; January 4, 2009

  • Get week ending date from Year and Week Number

    I would like to display the week ending date in a Report.
    My dataset query has grouped the results by year and week number, so I am trying to construct the week ending date from year and week number.

    Week end date can be got as below
    =DateAdd(DateInterval.WeekOfYear,CInt(Fields!WeekNumber.Value) -1,DateAdd(DateInterval.Year,(Cint(Fields!Year.Value) - 1900),CInt("12/31/1899")))
    Please Mark This As Answer if it solved your issue
    Please Vote This As Helpful if it helps to solve your issue
    Visakh
    My Wiki User Page
    My MSDN Page
    My Personal Blog
    My Facebook Page

  • PDF form Week ending date auto populate

    i have a pdf form i am doing. it has a java script to make the week ending date populate other fields and minus a day.
    if (WEEK_ENDING.rawValue == null)
    {$.rawValue = "";}
    else
    {Num2Date(Date2Num(WEEK_ENDING.formattedValue, DateFmt(1)) - 0, DateFmt(1));}
    endif
    this works for the first date, but when i change it to
    if (WEEK_ENDING.rawValue == null)
    {$.rawValue = "";}
    else
    {Num2Date(Date2Num(WEEK_ENDING.formattedValue, DateFmt(1)) - 1, DateFmt(1));}
    endif
    it does not work. any idea what i am doing wrong?
    Tina

    Hi Tina,
    Well at first look, seems like you mixed FormCalc and JavaScript together...
    Num2Date and Date2Num can only be used in FormCalc, and you can't use these { } in FormCalc
    You should be using the if (), then, else, elseif, endif for FormCalc
    if (WEEK_ENDING.rawValue == null) then
         $.rawValue = ""
    else
         Num2Date(Date2Num(WEEK_ENDING.formattedValue, DateFmt(1)) - 1, DateFmt(1))
         or
         Num2Date(Date2Num(DateTimeField1.rawValue, "YYYY-MM-DD") + 1, DateFmt(1))
    endif

  • Adding a summary column in a table which contains the start and end dates in the week

    Hi,
    I've got a DIMENSION DATE table and want to add in another column which shows the start and end date of the week.
    See below, the new column is WEEKOFYEARTEXT.
    Does anybody know how i may generate this column using SQL and using the existing columns?
    Umar Javed

    See:  http://www.sqlusa.com/bestpractices/datetimeconversion/
    DECLARE @Year INT = '2015';
    WITH cteDays AS (SELECT DayOfYear=Dateadd(dd, number,
    CONVERT(DATE, CONVERT(char(4),@Year)+'0101'))
    FROM master.dbo.spt_values WHERE type='P'),
    CTE AS (SELECT DayOfYear, WeekOfYear=DATEPART(week,DayOfYear)
    FROM cteDays WHERE YEAR(DayOfYear)= @YEAR)
    SELECT WeekOfYear, StartOfWeek=MIN(DayOfYear), EndOfWeek=MAX(DayOfYear)
    FROM CTE GROUP BY WeekOfYear ORDER BY WeekOfYear;
    WeekOfYear StartOfWeek EndOfWeek
    1 2015-01-01 2015-01-03
    2 2015-01-04 2015-01-10
    3 2015-01-11 2015-01-17
    4 2015-01-18 2015-01-24
    5 2015-01-25 2015-01-31
    6 2015-02-01 2015-02-07
    7 2015-02-08 2015-02-14
    8 2015-02-15 2015-02-21
    Kalman Toth Database & OLAP Architect
    SQL Server 2014 Database Design
    New Book / Kindle: Beginner Database Design & SQL Programming Using Microsoft SQL Server 2014

  • I have a PPC iMac 10.4.11 and will shortly buy a new i Mac.  What is the best way to transfer all my HD date from old to new? Thank you!

    I have a PPC iMac 10.4.11 and will shortly buy a new i Mac.  What is the best way to transfer all my HD date from old to new? Thank you!

    Migrating from PPC Macs to Intel Macs:
    https://discussions.apple.com/docs/DOC-2295
    How to use Migration Assistant:
    http://support.apple.com/kb/HT4413?viewlocale=en_US
    http://support.apple.com/kb/TS1963
    Troubleshooting Firewire target disk mode:
    http://support.apple.com/kb/HT1661

  • My Mum( a pensioner) is wanting to purchase both an iPhone and iPad.  What is the best way for her to manage her data /calls/txt etc. obviously the cost needs to be as low as possible.  Currently does not have WiFi but uses dongle

    My Mum( a pensioner) is wanting to purchase both an iPhone and iPad.  What is the best way for her to manage her data /calls/txt etc. obviously the cost needs to be as low as possible.  Currently does not have WiFi but uses dongle

    My Mum( a pensioner) is wanting to purchase both an iPhone and iPad.  What is the best way for her to manage her data /calls/txt etc. obviously the cost needs to be as low as possible.  Currently does not have WiFi but uses dongle

  • Grouping Via Week Ending Date

    Hi All,
    I have transaction line data for each day for our customer and i would like to group via Week Ending date.  Our week runs from Sunday to Saturday.
    If i Add the transaction date to the group expert it allows me to group via week(perfect) but does it via week commencing.  I see you can group via formula, does any one know how you can get the grouping via Week Ending.
    thanks for any help and advise.
    mike

    Try using this formula...
    DateAdd("ww", DateDiff("ww", #1/6/1900#, {TableName.DateField}), #1/6/1900#)
    This formula will calculate the "Following Saturday" for any given date. If the date supplied is a Saturday, it will return that same date.
    So...
    11/2/2010 &gt; 11/6/2010
    11/13/2010 &gt; 11/13/2010
    11/14/2010 &gt; 11/20/2010
    HTH,
    Jason

  • Week Ending Date Calculation

    Hi -
    I need to calculate weekending in OBIEE Answers.
    The week will start with Sunday and end with Saturday. The week ending date for this week should be Friday of this week.
    for example :
    7th October 2012 (Sunday) - 13th October 2012(Saturday) Week Ending date should be (12th October 2012)
    Thanks!

    user8021111 wrote:
    Hi -
    Sorry.. this doesn't solved my issue..
    for example in column A I have dates like
    Column A Column B(Should be populate the week Ending Date)
    30 SEP 2012 05 OCT 2012
    01 OCT 2012 05 OCT 2012
    02 OCT 2012 05 OCT 2012
    03 OCT 2012 05 OCT 2012
    04 OCT 2012 05 OCT 2012
    05 OCT 2012 05 OCT 2012
    06 OCT 2012 05 OCT 2012
    07 OCT 2012 12 OCT 2012
    08OCT2012 12 OCT 2012
    09 OCT 2012 12 OCT 2012
    10 OCT 2012 12 OCT 2012
    11 OCT 2012 12 OCT 2012
    12 OCT 2012 12 OCT 2012
    13 OCT 2012 12 OCT 2012
    The week ending date should be considered as friday of the week..the week will start from sat and end with sund.. this all should fall under friday of that week..
    Sorry for the inconvenience caused... Thanks again.
    Thanks,Next time give the examples the first time, it'll be easier to see. Here is the formula for column B:
    TIMESTAMPADD(SQL_TSI_DAY, DAYOFWEEK(column_A)*-1+6, column_A)

  • What is the best way to transfer all of my data from my iPod touch 3rd generation to my iPhone 4s?

    I have a 3rd generation iPod touch, and now I am getting an iPhone 4s. What is the best way to transfer all of my data, including paid-for apps and music, from the iPod to the iPhone without losing anything? Can I just do it through iTunes or the iCloud? I have never used iCloud before.

    Follow the directions here:
    http://support.apple.com/kb/HT2109

Maybe you are looking for