Cfloop: looping over a date or time range

This question was posted in response to the following article: http://help.adobe.com/en_US/ColdFusion/10.0/CFMLRef/WSc3ff6d0ea77859461172e0811cbec22c24-7 1a9.html

Currently the Attributes table says "1 day" is the default value for the 'index' attribute.  However, it is actually the default value for the 'step' attribute.  So the "1 day" should probably be moved from 'index' to 'step'.
Thanks!,
-Aaron

Similar Messages

  • Time difference by date by time range - a better way?

    Someone suggested this is a better place for my question:
    Hi
    I need to display the difference in time - every day for different time ranges,
    Example 1-2 pm, 4-5 pm, 7-8 pm. And I need the time difference in 2 dates in the past week for each of these ranges everyday.
    example
    Date Diff Range
    01/01/2007 00:01 1-2pm
    01/02/2007 00:03
    01/03/2007 00:10
    01/04/2007 00:05
    01/05/2007 00:23
    01/01/2007 00:10 4-5pm
    01/02/2007 00:13
    01/03/2007 00:11
    01/04/2007 00:15
    01/05/2007 00:23
    01/01/2007 01:10 7-8pm
    01/02/2007 00:13
    01/03/2007 00:10
    01/04/2007 00:11
    01/05/2007 00:21
    One way to achieve this is to have multiple unions for each day and each time range.
    Example:
    select
    from
    where dt_tm between
    to_date(to_char((sysdate-5),'mm/dd/yyyy')||' 13:00','mm/dd/yyyy hh24:mi:ss')and
    to_date(to_char((sysdate-5),'mm/dd/yyyy')||' 14:00','mm/dd/yyyy hh24:mi:ss')
    union
    select
    from
    where dt_tm between
    to_date(to_char((sysdate-5),'mm/dd/yyyy')||' 16:00','mm/dd/yyyy hh24:mi:ss')and
    to_date(to_char((sysdate-5),'mm/dd/yyyy')||' 17:00','mm/dd/yyyy hh24:mi:ss')
    union
    select
    from
    where dt_tm between
    to_date(to_char((sysdate-5),'mm/dd/yyyy')||' 19:00','mm/dd/yyyy hh24:mi:ss')and
    to_date(to_char((sysdate-5),'mm/dd/yyyy')||' 20:00','mm/dd/yyyy hh24:mi:ss')
    This will give me the required information for only one day - and that is for sysdate-5.
    I will have same nyumber of unions for each day.
    Is there a better way to accomplish the same?
    Any help appreciated.
    Thx!

    Hi
    Sorry for the late response but better late than never:::
    I have gotten the answer of getting data for previous 5 days. I have changed the time between statement and is given below(*).
    Here is a reply to all the questions you had asked in response to my questions.
    What data you have? What parameters are you going to input?
    I have already given sample data in my post.
    There are no input parameters.
    You are talking about the difference - between what is this difference?
    Difference is the difference between 2 timestamp datatypes in 2 different tables (as you may see in the query)
    The field diff - is it varchar2 like '1-2 pm' or what?
    I didnt understand your question. What do you get when you subtract two timestamp datatypes - that should be the datatype - if I have understood your question. Not sure if thats what you asked.
    But IMHO it's impossible to get such a result, of course, if dt_tm in the query is the same as Date in the result!
    The time components in the queries are different. If you see:
    1st Query:...
    where dt_tm between
    to_date(to_char((sysdate-5),'mm/dd/yyyy')||' 13:00','mm/dd/yyyy hh24:mi:ss')and
    to_date(to_char((sysdate-5),'mm/dd/yyyy')||' 14:00','mm/dd/yyyy hh24:mi:ss')
    2nd Query:....
    where dt_tm between
    to_date(to_char((sysdate-5),'mm/dd/yyyy')||' 16:00','mm/dd/yyyy hh24:mi:ss')and
    to_date(to_char((sysdate-5),'mm/dd/yyyy')||' 17:00','mm/dd/yyyy hh24:mi:ss')
    3rd Query:
    where dt_tm between
    to_date(to_char((sysdate-5),'mm/dd/yyyy')||' 19:00','mm/dd/yyyy hh24:mi:ss')and
    to_date(to_char((sysdate-5),'mm/dd/yyyy')||' 20:00','mm/dd/yyyy hh24:mi:ss')
    First should be between 1 and 2 pm for sysdate-5.
    I need starting previous 5 days till sysdate.
    Second is between 4 and 5 pm again for sysdate-5.
    I need starting previous 5 days till sysdate.
    Same with 3rd.
    My final query is something like this:
    select t1.dt_tm, count(t1.id), '1 - 3 am' as period
    from table1 t1, table2 t2
    where t1.id = t2.id
    and dt_tm between
    to_date(to_char((sysdate-5),'mm/dd/yyyy')||' 13:00','mm/dd/yyyy hh24:mi:ss')and
    to_date(to_char((sysdate-5),'mm/dd/yyyy')||' 14:00','mm/dd/yyyy hh24:mi:ss')
    group by t1.dt_tm
    union
    select t1.dt_tm, count(t1.id), '4 - 5 pm' as period
    from table1 t1, table2 t2
    where t1.id = t2.id
    and dt_tm between
    to_date(to_char((sysdate-5),'mm/dd/yyyy')||' 16:00','mm/dd/yyyy hh24:mi:ss')and
    to_date(to_char((sysdate-5),'mm/dd/yyyy')||' 17:00','mm/dd/yyyy hh24:mi:ss')
    group by t1.dt_tm
    union
    select t1.dt_tm, count(t1.id), '7 -8 pm' as period
    from table1 t1, table2 t2
    where t1.id = t2.id
    and dt_tm between
    to_date(to_char((sysdate-5),'mm/dd/yyyy')||' 19:00','mm/dd/yyyy hh24:mi:ss')and
    to_date(to_char((sysdate-5),'mm/dd/yyyy')||' 20:00','mm/dd/yyyy hh24:mi:ss')
    group by t1.dt_tm
    I need for the last 5 days and what i can think of is have 5 different queries for past 5 days and 3 queries per day for the 3 different time periods. This would mean 15 queries. Was wondering if there is a better way to achieve the same?
    Any help appreciated.
    Thx!

  • Cfloop: looping over a query

    This question was posted in response to the following article: http://help.adobe.com/en_US/ColdFusion/10.0/CFMLRef/WSc3ff6d0ea77859461172e0811cbec22c24-7 1a8.html

    The getEmployees() method in example of dynamic references usage must be returns query (not string), right?

  • CFScript Math expression - Summing up looped over data

    If I loop over numeric data and  I want to sum that data I am looking for the correct manner to do so. Of course I want to do this in cfscript.
    I know that I could go the route of doing a one demensional array and using the array sum function and I could also use stauctures.
    I am interested in different solutions to this problem.
    My end state is that I need to sum and average looped dynamic data for reporting purposes.
    For purposes of example static values will be helpful for better understanding.
    Thanks in advance.

    Owain,
    This is what I came up with and it outputs the looped data. Now I am trying to add it up and average the results.
    BTW Adam,
    Be delusional on a Microsoft or Oracle forum board.
    Now that would be some fun reading cutting through those flames! (In a patronising Kinda Way!).

  • Looping Over INSERT

    I've got a form. The form asks the visitor their address
    (first name, last name, street address, apartment number, city,
    state, and zip code... each a separate text field). This form is
    repeated 10 times on the page, allowing the visitor to enter
    multiple addresses. I've given each form field a unique name by
    just appending "_1" or "_2" after it. For example, my fields are
    named...
    FIRST FORM BLOCK
    first_name_1
    last_name_1
    SECOND FORM BLOCK
    first_name_2
    last_name_2
    Each form block (address) will be inserted into a table in my
    database as a new row. Is there a quick and easy way to loop over
    the insert 10 times, rather than have 10 separate INSERT statements
    in my code? A CFLOOP would work just fine if not for dynamic form
    field names, but I would have to take into account the "_X". I want
    to say I've done this before; I'm just overthinking.

    <cfloop from="1" to="10" index="i">
    <cfquery ...>
    INSERT INTO ...
    (aCol,bCol,cCol...)
    <!--- The important part, accessing the form structure
    with array
    notation --->
    #form['first_Name_' & i]#,
    #form['last_Name_' & i]#
    </cfquery>
    </cfloop>
    The array notation for a complex variables is a very powerful
    concept.
    Many advance techniques can be used with it.

  • Discrete time range over date range  (using CR X1)

    Post Author: sjr
    CA Forum: Formula
    Can anyone show me how to select data over a discrete time range i.e. 6 p.m. till 11 p.m. per day, over a period of a month ?
    Using the data time parameter gives me data from 6p.m. on startdate right through till 11p.m. on endate.

    Here's a more detailed description...
    Create two formula fields to split the date and time from the data records (ds prefixed):
    dsDate
    dsTime
    Create two formula fields to split the date and time from the parameter fields (pm prefixed):
    pmStartDate
    pmStartTime
    pmStartDate
    pmStartTime
    Use your new formula fields in the record selector. Get to this off the Report menu button (in CR 2008):
    Report | Select Expert... | Record.
    You can pick the formula fields in the Forumula Editor to create something like:
    ({@dsDate} > {@pmStartDate} and
    {@dsDate} < {@pmEndDate}) and
    ({@dsTime} > {@pmStartTime} and
    {@dsTime} < {@pmEndTime)
    Tim

  • Data acquisition time not continuous, but starting over and over again

    Hi,
    My data acquisition time is not continuous but loops over and over
    again.  Could someone please take a look at my vi to see if you
    have any thoughts on how to fix this.  Also, I tried to set up my
    vi so that I could take the mean of the signal at any time I
    choose.  However, at the same instance that the data acquistion
    time "starts over" again, the mean is calculated (before I trigger it to take the mean)
    I have attached my vi and my output file as a text file so that what
    I'm trying to say will (hopefully) make a bit more sense. 
    Thanks for your help in advance!
    Sherri
    Attachments:
    Datalog1 71805.vi ‏1252 KB

    Hi,
    Thanks for responding to my question. Attached is the vi with added
    comments as to what I think I am doing.  By DAQ time, I mean the
    first column of data that is in the data file that I attached
    previously.  I am only simulating a signal (at the beginning) so
    that I can program in my office.  I do, however, have the same
    problem as stated above when I change the simulate signal to DAQmx
    using my instrument.
    I hope this clearer.  If not, I'll try again. 
    Thanks so much!
    Sherri
    Attachments:
    Datalog1 71805 83.vi ‏1228 KB

  • Collapsing rows - date/time ranges

    Hi,
    I need to collapse date/time ranges (1 range per row) into the smallest continuous block for a particular item, instance (date/time).
    For example,
    CREATE TABLE "BLOCK_TEST"
       "ID" NUMBER,
       "START_BLK" DATE,
       "STOP_BLK" DATE
    alter session set nls_date_format = "YYYY-MM-DD HH24:MI";
    INSERT INTO BLOCK_TEST ("ID","START_BLK","STOP_BLK") VALUES (1, TO_DATE('2006-07-03 01:00'), TO_DATE('2006-07-03 01:30'));
    INSERT INTO BLOCK_TEST ("ID","START_BLK","STOP_BLK") VALUES (1, TO_DATE('2006-07-03 01:30'), TO_DATE('2006-07-03 02:00'));
    INSERT INTO BLOCK_TEST ("ID","START_BLK","STOP_BLK") VALUES (1, TO_DATE('2006-07-03 02:00'), TO_DATE('2006-07-03 02:30'));
    INSERT INTO BLOCK_TEST ("ID","START_BLK","STOP_BLK") VALUES (1, TO_DATE('2006-07-03 02:30'), TO_DATE('2006-07-03 03:00'));
    INSERT INTO BLOCK_TEST ("ID","START_BLK","STOP_BLK") VALUES (1, TO_DATE('2006-07-03 03:30'), TO_DATE('2006-07-03 04:00'));
    INSERT INTO BLOCK_TEST ("ID","START_BLK","STOP_BLK") VALUES (1, TO_DATE('2006-07-03 04:00'), TO_DATE('2006-07-03 04:30'));
    INSERT INTO BLOCK_TEST ("ID","START_BLK","STOP_BLK") VALUES (2, TO_DATE('2006-07-03 02:00'), TO_DATE('2006-07-03 02:30'));
    INSERT INTO BLOCK_TEST ("ID","START_BLK","STOP_BLK") VALUES (2, TO_DATE('2006-07-03 02:30'), TO_DATE('2006-07-03 03:00'));
    INSERT INTO BLOCK_TEST ("ID","START_BLK","STOP_BLK") VALUES (2, TO_DATE('2006-07-03 03:00'), TO_DATE('2006-07-03 03:30'));
    select * from block_test order by id, start_blk;
    ID      START_BLK               STOP_BLK
    1     2006-07-03 01:00     2006-07-03 01:30
    1     2006-07-03 01:30     2006-07-03 02:00
    1     2006-07-03 02:00     2006-07-03 02:30
    1     2006-07-03 02:30     2006-07-03 03:00
    1     2006-07-03 03:30     2006-07-03 04:00
    1     2006-07-03 04:00     2006-07-03 04:30
    2     2006-07-03 02:00     2006-07-03 02:30
    2     2006-07-03 02:30     2006-07-03 03:00
    2     2006-07-03 03:00     2006-07-03 03:30If ID = 1 and my instance is 2006-07-03 01:45, I need to obtain 2006-07-03 01:00 as the start of the block and 2006-07-03 03:00 as the end - notice the gap from 3:00 to 3:30 so the end would not be 4:30.
    I can do this in a procedure but I was wondering if this could be done with just SQL?
    Any hints, suggestions or opinions would be welcome.
    Thanks,
    dfg
    EDIT: After re-reading this, need to clarify that I don't need to actually change or update the rows, just query to get the start and end of the block in question...
    Message was edited by:
    Indy

    There might be better ways but the following worked for me
    SQL> select
      2        first_value(start_blk) over (partition by id ORDER BY lvl desc),
      3        first_value(stop_blk) over (partition by id ORDER BY lvl desc)
      4  from (select level lvl, id, connect_by_root start_blk start_blk, stop_blk
      5        from (select id , start_blk, stop_blk
      6              from   block_test
      7              where  id=1
      8             )
      9        connect by prior stop_blk=start_blk
    10        order by level desc
    11       )
    12  where to_date('2006-07-03 01:45', 'YYYY-MM-DD HH24:MI') between start_blk and stop_blk
    13  and rownum < 2
    14  ;
    FIRST_VALUE(STAR FIRST_VALUE(STOP
    2006-07-03 01:00 2006-07-03 03:00
    SQL> select
      2        first_value(start_blk) over (partition by id ORDER BY lvl desc),
      3        first_value(stop_blk) over (partition by id ORDER BY lvl desc)
      4  from (select level lvl, id, connect_by_root start_blk start_blk, stop_blk
      5        from (select id , start_blk, stop_blk
      6              from   block_test
      7              where  id=1
      8             )
      9        connect by prior stop_blk=start_blk
    10        order by level desc
    11       )
    12  where to_date('2006-07-03 03:15', 'YYYY-MM-DD HH24:MI') between start_blk and stop_blk
    13  and rownum < 2
    14  ;
    no rows selected
    SQL> select
      2        first_value(start_blk) over (partition by id ORDER BY lvl desc),
      3        first_value(stop_blk) over (partition by id ORDER BY lvl desc)
      4  from (select level lvl, id, connect_by_root start_blk start_blk, stop_blk
      5        from (select id , start_blk, stop_blk
      6              from   block_test
      7              where  id=1
      8             )
      9        connect by prior stop_blk=start_blk
    10        order by level desc
    11       )
    12  where to_date('2006-07-03 03:45', 'YYYY-MM-DD HH24:MI') between start_blk and stop_blk
    13  and rownum < 2
    14  ;
    FIRST_VALUE(STAR FIRST_VALUE(STOP
    2006-07-03 03:30 2006-07-03 04:30
    SQL>

  • Looping over arraycollection with sap data

    Hello,
    I asked a lot of persons but i still have a problem.
    I am trying to make a organizational chart in Adobe Flex with data out of the SAP system.
    When I try to access my data that I have given trough the Flash Islands container it doesn’t work.
    I do:
    [Bindable]
    Public var datasource:Arraycollection;
    Then I want to loop over this datasource with a for loop but it says that the object is null.
    for (i = o; i < datasource.length; i++)
    When I use datasource as dataprovider for a datagrid in Flex, that works perfect.
    Please answer fast because I need it for school.
    greetings

    Hello,
    I asked a lot of persons but i still have a problem.
    I am trying to make a organizational chart in Adobe Flex with data out of the SAP system.
    When I try to access my data that I have given trough the Flash Islands container it doesn’t work.
    I do:
    [Bindable]
    Public var datasource:Arraycollection;
    Then I want to loop over this datasource with a for loop but it says that the object is null.
    for (i = o; i < datasource.length; i++)
    When I use datasource as dataprovider for a datagrid in Flex, that works perfect.
    Please answer fast because I need it for school.
    greetings

  • How do I Show date and time when I hover over clip like in iMovie

    How do I get FCPX 10.6 to show date and time when I hover over a clip? I can so it in I movie and as I move over my clips the date/time is shown. I need it for that specific point in the clip not just the record start time.

    I realize that my needs are outside of the normal editing workflow. I am a private investigator and last week I shot over 6 hours of surveillance video on a Sony video camera. Within this 6 hours of video there is at most 2 minutes of actual footage of my subject. So what I wanted to do was just import the parts of the clip I want, so I can avoid importing the whole 6 hours, and then add a text title of some sort that shows the date/time. My problem is that once I get this clip I have easy way of establising the TOD short of taking the clip capture time and then counting up using the SMTPE Timecode. In this regard iMovie makes it easier because I can just hover over the clip and see the TOD of that specific frame. iMovie on the other hand would force me to import the whole 6 hour video so i'm left moving between both programs which is less than ideal.

  • Why are date and time strings lost when indexing an array in a for loop

    Hi, 
    I have an application where i'm reformatting data from a spreadsheet for graphical display on a LabVIEW dashboard.
    the original spreadsheet has date and time values in separate columns, and i'm merging them and converting to a timestamp value.  But something's not working.  Does anyone know why the string value is lost when the array indexes into this for loop?
    Attachments:
    failed array index.png ‏142 KB

    Can you attach your VI with some typical values? (e.g. create in indicator on the 2D array, run your VI, then turn the indicator (now containing data) into a diagram constant). Place the FOR loop related code and that diagram constant into a new VI and attach it here.
    How many times does the FOR loop run? Could it be that the last element of each 1D array is an empty string? (unless you put a wait inside the FOR loop, you'll never see the other elements in the probe)
    LabVIEW Champion . Do more with less code and in less time .

  • Why does my mac mini's mouse show a pinwheel every time I hover over the date area? Also, sometimes the date shows up incorrectly.

    Why does my mac mini's mouse show a pinwheel every time I hover over the date area? Also, sometimes the date/time shows up incorrectly. It started happening after I updated to OS X Mountain Lion.

    Launch the Console application in any of the following ways:
    ☞ Enter the first few letters of its name into a Spotlight search. Select it in the results (it should be at the top.)
    ☞ In the Finder, select Go ▹ Utilities from the menu bar, or press the key combination shift-command-U. The application is in the folder that opens.
    ☞ Open LaunchPad. Click Utilities, then Console in the icon grid.
    Make sure the title of the Console window is All Messages. If it isn't, select All Messages from the SYSTEM LOG QUERIES menu on the left.
    Click the Clear Display icon in the toolbar. Try the action that you're having trouble with again. Post any messages that appear in the Console window – the text, please, not a screenshot.
    When posting a log extract, be selective. In most cases, a few dozen lines are more than enough.
    Please do not indiscriminately dump thousands of lines from the log into a message.
    Important: Some private information, such as your name, may appear in the log. Edit it out by search-and-replace in a text editor before posting.

  • How to capture file modification date and time over the web

    HI!
    I am creating a web based application and I am using webutil package for al lot of my work being that I ma working with renamin,deleting and uploading files for a users machine to the database. There is one functionality thing that I have to do in this application that webutil does not take care of and that is capturing the modification date and time from a file on the users machine. Please help me capture the date and time of a file on the users machine.
    Thanks!

    Since webutil allows you to write file on client PC directory, then you first create a directive file, then host that directive file. the directive file content is just the command lines when you manually do it on PC.
    Refer the ideas--just the ideas not the same built-ins in this URL:
    Hyperlink in forms

  • Date / Time Range Selection

    Post Author: LDFCC
    CA Forum: Formula
    I am trying to create a report using Crystal Report XI which prompts the user to enter a start date / end date / start time & end time. For example, the person will select 9/19 (start date), 9/20 (end date), 10 AM (Start time), 10:30 AM (End Time). The report correctly pull up all tickets from 9/19 till 9/20 but only displays the tickets from 9/19 from 10 - 10:30 AM and 9/20 from 10 - 10:30 AM. I need it to show all tickets from 9/19 10:00 AM till 9/20 10:30 AM. Both the time and date are two seperate fields in the database. Any help is greatly appreciated.
    Thanks.

    Post Author: LDFCC
    CA Forum: Formula
    yangster:
    since you are dealing with 2 seperate fields for date and time the first thing you want to do is merge them back into one so things are consistenttry putting this in your selection expert
    datetimevar begin_date_time := datetime(cdate(?begin date), ctime(?begin time));datetimevar end_date_time := datetime(cdate(?end date), ctime(?end time));datetime(cdate(date_field), ctime(time_field)) in begin_date_time to end_date_time
    I tried this and I get an error because it says that (?begin date), (?begin time), (?end time), and (?end date) all have to be date time fields but they are not the date field is only date field and same with the time fields. Any suggestions?

  • Loop over data

    I have returned a dataset and one of the fields from the
    dataset is a comma delimited list, is there a way to loop over this
    list and display the values.

    Hi Martin,
    you assign the VARC incorrectly.
    L_ACC = VARC(VACVTE01).
    should be
    L_OBSERV = VARC(VACVTE01).
    Regards,
    Marc
    SAP NetWeaver RIG

Maybe you are looking for

  • Safari crashes everytime I try to open certain pages

    Hello, I'm having the same problem as Teresa in her post. I tried doing the steps mentinoned, nevertheless Safari still crashes at the same page everytime. I've got two (2) macs and the application crashes at the same place everytime i try to do some

  • Please help me to remove NEXUS S from my shopping cart

    A couple days ago, 16th, when the NEXUS S came out. I added them in my bestbuy account shopping cart to verify the price for my plan here. But since then, they are staying in my shopping cart for ever. I can't remove them. Now the five cellphone item

  • How to load .jar files when not specified in the .jnlp file

    Hello, We are deploying an application with JWS but due to the nature of this app, we need to download additional jar file only when the user has been authenticated. The jar file(s) we need to download can hardly be predicted (in term of name) and th

  • How can I do this input help in the Input ready query

    Dear all, Do you konw this function? The following steps is that: 1,I create the Input ready Query. 2,I can insert the new record. 3,I can use the input help for the characteristics. 4,When I double the space, I got the pop-up for input help. 5,I wan

  • Clicking FLASH elements in the Web Browser

    The website that I am working on has numerous FLASH elements in it and I was wondering if there is anyway to make it so that users browsing the site with Internet Explorer do not have to click on the FLASH elements before navigating the site. Any hel