Start/End Date parameters that check day of week and using to set default values.

Hi,
I've got a report that presents data between a start and an end date.
I want it to check if it's a monday and present data from the previous week, otherwise present data from this week.
For the "Default" value of parameter @startdate, I've got the following expression:
=iif(WeekdayName(DatePart("w", Today)) = "Monday",DateAdd("d",-8,Today()),DATEADD("d", 1 - DATEPART(DateInterval.WeekDay, Today(),FirstDayOfWeek.Sunday), Today()))
for @enddate I've got default value:
=iif(WeekdayName(DatePart("w", Today)) = "Monday",DateAdd("d",-1,Today()),DATEADD("d", 7 - DATEPART(DateInterval.WeekDay, Today(),FirstDayOfWeek.Sunday), Today()))
but it doesn't appear to be working, I've checked 
WeekdayName(DatePart("w", Today))
as an expression in a text box and it evaluates to Monday but my IIF statement above always uses the DATEADD line therefore not returning "Monday" as the value (even though it is).
Is it a problem that the parameters are of Data/Time data type and I'm trying to evaluate as type text?
Any help would be appreciated.
Thanks :)

StartDate
=IIf(DateDiff(DateInterval.Day,CDate("01/01/1900"),Today) Mod 7 =0,DateAdd(DateInterval.WeekOfYear,DateDiff(DateInterval.WeekOfYear,CDate("01/01/1900"),Today)-1,CDate("01/01/1900")),DateAdd(DateInterval.WeekOfYear,DateDiff(DateInterval.WeekOfYear,CDate("01/01/1900"),Today),CDate("01/01/1900")))
EndDate
=IIf(DateDiff(DateInterval.Day,CDate("01/01/1900"),Today) Mod 7 =0,DateAdd(DateInterval.Day,-1,DateAdd(DateInterval.WeekOfYear,DateDiff(DateInterval.WeekOfYear,CDate("01/01/1900"),Today),CDate("01/01/1900"))),DateAdd(DateInterval.Day,-1,DateAdd(DateInterval.WeekOfYear,DateDiff(DateInterval.WeekOfYear,CDate("01/01/1900"),Today)+1,CDate("01/01/1900"))))
Please Mark This As Answer if it solved your issue
Please Mark This As Helpful if it helps to solve your issue
Visakh
Hi, 
This one works but it results to be between monday and saturday, how to make it between sunday and saturday?

Similar Messages

  • Creating a fiscal date table that includes Day of Year and Week of Year column

    Hi,
    Our fiscal year runs between 1st October through to 30th September and I'm trying to create a date table that I can use to represent this in Powerpivot (I'm using Excel 2013). I had no probably creating columns for Fiscal month or fiscal year, however I am
    having issue breaking it down more than that, specifically I cannot work out how to calculate:
    - day of the year
    - week of the year (with week one starting on the first day of the year rather than the first Monday)
    I worked out how to do the day of the year until I had to try and account for leap years which broke the formula I had! Can anyone please recommend solutions, I cannot see anything online about this. Obviously I know that it is simple to do this for a normal
    calendar year but this approach doesn't work with a custom fiscal year.
    Whilst it is useful for several reasons, my main reason for wanting week is so that I can plot my Pivotcharts more smoothly (although I may have missed an easier way to do that).
    Thanks,
    James

    For my example I started with 1 column in Power Pivot called [Date]
    I created the following Columns
    [DayofMonth] =Day([Date])
    [MonthNumber] =Month([Date])
    [Fiscal Year] =IF([MonthNumber]< 10, Year([Date]), (Year([Date])+1))
    [Fiscal Day] =[Date] - DATE(([Fiscal Year] -1), 10,1) +1
    [Fiscal Week] =RoundUp([Fiscal Day] / 7, 0)
    Change [Date] to whatever your date column is and those DAX formulas will get you what you need

  • How to set default values on the screen painter parameters?

    Hello ABAP Gurus,
    I would just want to ask how to set default values on the screen painter parameters.
    Thank you for your replies.

    Hi,
    To set default values for screen painter parameters initialize the field names with default values in the PBO module....
    say u have the field name as f_field1....
    in the PBO of that screen initialize it....
    f_field1 = '100'  "here 100 is the default value.
    <b>reward points if useful.</b>
    regards,
    Vinod Samuel.

  • How do you use the "Item Containing Start/End Date" in a Calendar?

    Hi
    I want to do a calendar where the days shown will be conditional to a certain interval. Now I though I could achieve that using the Item Containing Start Date of a calendar. But it doesn't seem to work. In the help it says :
    Enter an item in the application which holds the start date of the calendar. The format of the date in this item must be YYYYMMDD.
    This is what I did here
    http://apex.oracle.com/pls/otn/f?p=34530:1::::::
    I have 3 fields. 2 for the Start Date and End Date and 1 for the "Date Item" parameter. Only the latter has an effect on the calendar display, the calendar only displays the month of the "Date Item" (in monthly mode).
    Wether or not I check "Begin at Start of Interval", it doesn't affect the way those fields are affecting the Calendar.
    So, how do we use that "Item Containing Start/End Date" parameter?

    Hello,
    does yout Script work when you begin with ?:
    Start-Process powershell -Verb runAs
    Best regards,
    Stefan
    German Orchestrator Portal ,
    My blog in English

  • Start/End dates for cProjects

    Hi,
    While creating a Project in PS, if the Start/ End date of the project is a weekend or holiday, the start of the cProject shifts to a working day u2013 is there a config to set this to take the actual date (working or holiday). Waiting for your reply @ earliest.
    Thanks & Regards,
    Gaurav

    Hi Gaurav,
    this shifting of the dates is likely a "feature" of the scheduling process. As soon as a calendar has been maintained for the objects the weekends are taken into account and the dates determined for the object being subject of scheduling and it is enforced that the dates are working days.
    To answer your question, if you maintained a calendar without weekends and public holidays - or no calendar at all - this shift won't occur.
    Hoping this helps...
    Best regards,
    Thomas

  • Need help in query to display dates as start, end dates

    Hi,
    I am trying the following output from the below table structure, data
    StartDAte Endate Reason          duration
    12-02-09 12:00:00 12-02-09 13:10:20 planned activity 1:10:20
    01-04-09 08:30:34 01-04-09 15:00:20 planned activity 6:30:34
    12-04-09 17:10:45 12-04-09 17:11:04 unplanned activity 0.10
    23-05-09 22:00:11 23:05-09 22:15:09 planned activity 0.15
    Mdate Reason omode host
    12-02-09 12:00:00 planned activity st 366
    12-02-09 13:10:20 planned activity ed 366
    01-04-09 08:30:34 planned activity st 366
    01-04-09 15:00:20 planned activity ed 366
    12-04-09 17:10:45 unplanned activity st 366
    12-04-09 17:11:04 unplanned activity ed 366
    23-05-09 22:00:11 planned activity st 366
    23:05-09 22:15:09 planned activity ed 366
    i tried with individual query but not able to get the output in combined way of start, end dates together with calculation of time difference, i tried using case options but not successful in resolve it.
    select to_char(mdate,'dd-mm-yyyyy hh24:mi:ss')startdate, reason
    from date_md where omode like 'st'
    order by o_char(mdate,'dd-mm-yyyyy hh24:mi:ss')startdate;
    select to_char(mdate,'dd-mm-yyyyy hh24:mi:ss')enddate, reason
    from date_md where omode like 'ed'
    order by o_char(mdate,'dd-mm-yyyyy hh24:mi:ss')enddate;
    any suggestions on type of query should be used is welcomed.

    Or maybe
    SQL>  WITH t AS (SELECT TO_DATE ('12-02-09 12:00:00',
                               'DD-MM-YY HH24:MI:SS')
                       event_date,
                      'planned activity' activity,
                      'st' start_end,
                      366 HOST
               FROM DUAL
               UNION ALL
               SELECT TO_DATE ('12-02-09 13:10:20',
                               'DD-MM-YY HH24:MI:SS'),
                      'planned activity',
                      'ed',
                      366
               FROM DUAL
               UNION ALL
               SELECT TO_DATE ('01-04-09 08:30:34',
                               'DD-MM-YY HH24:MI:SS'),
                      'planned activity',
                      'st',
                      366
               FROM DUAL
               UNION ALL
               SELECT TO_DATE ('01-04-09 15:00:20',
                               'DD-MM-YY HH24:MI:SS'),
                      'planned activity',
                      'ed',
                      366
               FROM DUAL
               UNION ALL
               SELECT TO_DATE ('12-04-09 17:10:45',
                               'DD-MM-YY HH24:MI:SS'),
                      'unplanned activity',
                      'st',
                      366
               FROM DUAL
               UNION ALL
               SELECT TO_DATE ('12-04-09 17:11:04',
                               'DD-MM-YY HH24:MI:SS'),
                      'unplanned activity',
                      'ed',
                      366
               FROM DUAL
               UNION ALL
               SELECT TO_DATE ('23-05-09 22:00:11',
                               'DD-MM-YY HH24:MI:SS'),
                      'planned activity',
                      'st',
                      366
               FROM DUAL
               UNION ALL
               SELECT TO_DATE ('23-05-09 22:15:09',
                               'DD-MM-YY HH24:MI:SS'),
                      'planned activity',
                      'ed',
                      366
               FROM DUAL)
    SELECT MIN (event_date) startdate,
           MAX (event_date) enddate,
           MAX (activity) reason,
           NUMTODSINTERVAL (MAX (event_date) - MIN (event_date),
                            'day')
            duration
    FROM t
    GROUP BY TRUNC (event_date)
    STARTDATE             ENDDATE               REASON             DURATION                                         
    23.05.2009 22:00:11   23.05.2009 22:15:09   planned activity   +00 00:14:57.999999                              
    12.02.2009 12:00:00   12.02.2009 13:10:20   planned activity   +00 01:10:19.999999                              
    01.04.2009 08:30:34   01.04.2009 15:00:20   planned activity   +00 06:29:45.999999                              
    12.04.2009 17:10:45   12.04.2009 17:11:04   unplanned activity +00 00:00:18.999999                              
    4 rows selected.

  • My problem started when i connected my iphone5 into mac book and i started restoring data, by that i lost my recent photo's ,i tryed a program but it was recovering the previous photo's not the recent once ... need ur help what to do plz....thank u

    my problem started when i connected my iphone5 into mac book and i started restoring data, by that i lost my recent photo's ,i tryed a program but it was recovering the previous photo's not the recent once ... need ur help what to do plz....thank u

    Not much you can do.  You overwrote your current data with older data when you restored the phone from that backup.  Your data's gone.

  • TS3591 Updated itunes - windows quickly shuts it down and says something about "Data Execution Prevention". I followed the instrucxtions to a dead end. I have re downloaded it twice and used the repair files once but get the same result. It worked fine be

    Updated itunes - windows quickly shuts it down and says something about "Data Execution Prevention". I followed the instrucxtions to a dead end. I have re downloaded it twice and used the repair files once but get the same result. It worked fine before I updated it to death.

    Try updating your QuickTime to the most recent version. Does that clear up the DEP errors in iTunes?

  • I have an iphone 4s that i got last week and i set it up just using the phone. today my dad restored it as my mothers iphone so i lost all of my data. I tried to restore it as my original phone i had but i exited out of itunes and now my phone wont showup

    I have an iphone 4s that i got last week and i set it up just using the phone. today my dad restored it as my mothers iphone so i lost all of my data. I tried to restore it as my original phone i had but i exited out of itunes and now my phone wont showup in itunes or on my computer

    Did you fail to import them to your computer before restoring?
    Not good.
    They are likely gone.
    You can try restoring from backup.

  • TS1814 hello i have  a trouble with my i phone... i was trying to update a new software and at the end it says that there is some error and i cannot turn my i phone bak on all it shows is itunes logo in the midlle and usb cable with an arrow pointing to t

    hello i have  a trouble with my i phone... i was trying to update a new software and at the end it says that there is some error and i cannot turn my i phone bak on all it shows is itunes logo in the midlle and usb cable with an arrow pointing at the logo. If anyone knows what it is and what i should do please get back to me as soon as possible many thanks.

    http://support.apple.com/kb/HT1808

  • I was charging my iPad2 and when reaching 90% it just went black and can't be started again. Anyone that have had this problem and know what to do?

    I was charging my iPad2 and when reaching 90% it just went black and can't be started again. Anyone that have had this problem and know what to do?

    I have had this problem several times. The iPad comes off charging with a black screen and only a hard reset works to get it back.  Then you have to go to settings to be sure nothing changed there.   
    I have had serveral hard resets and three restore operations and the problem recurs.  I am not sure if it is the iPad2 or an app that is causing the problem.   So far I can live with it as is. 
    Jay

  • I've lost iWeb and thus my web design.  I must start from scratch.  Should I reinstall iWeb 09 and use that, or is there a better way?

    I've lost iWeb and thus my web design.  I must start from scratch.  Should I reinstall iWeb 09 and use that, or is there a better way?

    The file you really need is named Domain.sites2 which resides in your   Home/Library/Application Support/iWeb foldler.  It's independent from the iWeb application. If it's not in there do you have a backup of your hard drive from an earlier time? 
    Resinatll iWeb 3 from the iLife 09 disk or wherever you got it from originally and then try what's described below:
    In Lion and Mountain Lion the Home/Library folder is now invisible. To make it permanently visible enter the following in the Terminal application window: chflags nohidden ~/Library and press the Return key - 10.7: Un-hide the User Library folder.
    To open your domain file in Lion or Mountain Lion or to switch between multiple domain files Cyclosaurus has provided us with the following script that you can make into an Applescript application with Script Editor. Open Script Editor, copy and paste the script below into Script Editor's window and save as an application.
    do shell script "/usr/bin/defaults write com.apple.iWeb iWebDefaultsDocumentPath -boolean no"delay 1
    tell application "iWeb" to activate
    You can download an already compiled version with this link: iWeb Switch Domain.
    Just launch the application, find and select the domain file in your Home/Library/Application Support/iWeb folder that you want to open and it will open with iWeb. It modifies the iWeb preference file each time it's launched so one can switch between domain files.
    WARNING: iWeb Switch Domain will overwrite an existing Domain.sites2 file if you select to create a new domain in the same folder.  So rename your domain files once they've been created to something other than the default name.
    OT

  • Setting Default value with SQL Query as Data Model

    Hi All,
    I am developing report based on SQL query.date set as 'SQL Query'. I have created two params start-date and end-date. I am fetching records from database between these two dates.
    I want to populate sysdate as a default values. I do not want to use datatemplate approach i mean using beforeReport trigger.
    Thansk,
    Vara

    Hi Vara,
    To set the default value for one of your parameters to SYSDATE you need to enter:
    {$SYSDATE()$}
    in the Default Value text box
    Is this what you require?
    Cheers
    Andy

  • How to set default value to date type attribute.

    Hi,
    How to set default value to date type attribute.
    E.g I want to set u201C01/01/1999u201D to date attributes.
    First i want to set value and then i want to fetch the same & want to check equals.
    please suggest solution.
    Regards,
    Smita

    Hi,
    In wdinit() method u can set the date
    DateFormat df = new SimpleDateFormat("MM/dd/yyyy");
    Date today = Calendar.getInstance().getTime();
    String reportDate = df.format(today);
    wdContext.currentContextElement().setFromDate(reportDate);
    Another way you have set the this formate like that
    1. Create a Simple type under "Dictionaries->SimpleType" called DateFormat
    2. Select the type as "date"
    3. Go to the "Representation" tab and set the format as "dd/MM/yyyy" (or whatever u want, but month should be MM)
    4.Bind the context attribute to the type created now.
    Hope this helps u.
    Best Regards
    Vijay K

  • Is there any way we can set default value for a Date Attribute to current date in Master Data Services

    Is there any way we can set default value for a Date Attribute to current date in Master Data Services.
    I as well wants to know that is there any posibility to show Calendar control while input data into respective date attributes.
    Thanks.

    Hi Anagha,
    So far i havent found any way to set todays date by default from MMI, but i guess this flow should work as workaroud
    1. Add buisness rule which can set a default value when Date = NULL/Blank
    2.get the entity table ,use -select EntityTable from mdm.tblEntity where Name = '<enter entity name>'
    3.Go to that table and add a after update trigger like
    if uda_<entityid>_<attributeid(Date attribute)> = default value
    update uda_<entityid>_<attributeid(Date attribute)> =getdate() where id = <LastUpdatedRow>
    I will check on this too from my side.
    By the way AFAIK i dont think so calendar control integration is possible .

Maybe you are looking for

  • SSRS cube report with parameters...and more

    Hi, I have created some basic SSRS reports in the past with parameters, but I was just given the following project by my manager and I would like to find out 2 things: 1.  Can this be accomplished using SSRS 2.  If yes, what are the High-Level steps

  • Importing WebService class into Forms10g

    Hi , I want to import webservice from Jdeveloper in Forms10g.I am using Jdeveloper 10.1.3.4 complaint with JDK 1.4. When I import the class in Forms10g from Jdeveloper it gave me error: Importing Class Proxy.classes.oracle.srtutorial.datamodel.proxy.

  • Getting lines in prints Photoshop CS6

    Hello, I am getting lines in my prints from PhotoShop CS6. My printer is the Canon MX522. Ive noticed that printing from other *dumb* programs such as Microsoft Paint the images look fine BUT with photoshop the images print ultra fast and have lines.

  • Opening IPhoto slideshow in iDVD

    I can see my IPhoto slideshow in the iDVD menu, but cannot open it. Any suggestions??

  • Invalid url after entering invalid credentials

    Hi when I give wrong password the autentication fails and stays on my login page(I expect this), but the url is geting suffixed by the global notification.. http://host1:7780/pls/apex/f?p=102:101:3194122067975525&notification_msg=Invalid%20Login%20Cr