Select records by date after first of next month

Hi
I have an asp app accessing a SQL Server db and am getting
myself into a tangle over dates. I have a date field ValidFromDt
(smalldatetime) and another date field ValidUntilDt which
respectively define when a record is valid from and until. I want
to select all records valid on the first of next month - i.e. were
now in July so I want any whose 'valid from' date is now or any day
up to 1 Aug but excluding those which expire before 1 Aug and also
those whose valid from date is 2 Aug or later. Whatever month we're
in, it is the first of next month I want to select up until.
Any suggestions much appreciated.
Thanks
TP

Try...
SELECT yourTable.* FROM yourTable WHERE
CSng(Month([ValidFromDt]))>CSng(Month(Date()))

Similar Messages

  • Default value of date as first day of month

    Ho can I make my default value of date parameter as first day of month? {$SYSDATE()$} gives only current date and we can make it like {$SYSDATE()-7$} if we want to minus 7 days but how can we set the default value to first day of month?

    I got the answer...It is {$FIRST_DAY_OF_MONTH()$} instead of {$SYSDATE()$}

  • Default posting date on first WD of month

    The posting date on first working day of the month was defaulted as last month's date. Eg. on first may, the default posting date was given as 30th april. why is this so.

    Hi,
    I am not sure for which transaction code you are making entry or it is general statement.
    generally, default date of posting is today's date as defined in own defult data with user ID
    Regards,
    Vinod

  • Select Record Between Date Gap-Oracle 11g, Windows 2008 server

    hello everyone,
    I have a sql query where I need to select only records with an 18 month gap between max(date) and previous date( no dates between max(date)
    and 18 month gap date), when I run the below query it should only select supid 130, not 120 (even though 120 does contain an 18 month gap date it also has a date that is less then the 18 month gap( '25-NOV-2012','DD-MON-YYYY').
    how would get the query to look back 18 months for the next date and evaluate the month_between.
    any help is greatly appreciated.
    example:
    create table supply(supID number(8), supply varchar2(20), supdate Date,supamount number(13,2));
    insert into supply values(100,'Tapes',to_date('01-AUG-2013','DD-MON-YYYY'),50.00);
    insert into supply values(100,'TV',to_date('01-APR-2013','DD-MON-YYYY'),250.00);
    insert into supply values(100,'Discs',to_date('25-DEC-2012','DD-MON-YYYY'),25.00);
    insert into supply values(120,'Tablets',to_date('25-AUG-2013','DD-MON-YYYY'),15.00);
    insert into supply values(120,'Paper',to_date('25-NOV-2012','DD-MON-YYYY'),35.00);
    insert into supply values(120,'Clips',to_date('20-NOV-2010','DD-MON-YYYY'),45.00);
    insert into supply values(120,'Binders',to_date('28-FEB-2012','DD-MON-YYYY'),25.00);
    insert into supply values(130,'Discs',to_date('25-JUL-2013','DD-MON-YYYY'),75.00);
    insert into supply values(130,'Calc',to_date('25-JAN-2012','DD-MON-YYYY'),15.00);
    insert into supply values(130,'Pens',to_date('15-DEC-2011','DD-MON-YYYY'),55.00);
       select * from supply p where to_char(p.supdate,'yyyy')='2013'
       and p.supid in(select s.supid from supply s where months_between(s.supdate,p.supdate)<-18)
         SUPID SUPPLY               SUPDATE    SUPAMOUNT
           120 Tablets              25-AUG-13         15
           130 Discs                25-JUL-13         75

    Something like this?
    select
    from (
    select
      supid
    , supply
    , supdate
    , supamount
    , lead(supdate) over (partition by supid order by supdate desc) ldate
    from supply
    where
    months_between(supdate,ldate) >= 18
    SUPID
    SUPPLY
    SUPDATE
    SUPAMOUNT
    LDATE
    130
    Discs
    07/25/2013
    75
    01/25/2012
    Ok. i see you want only he diff to max date.
    select
    from (
    select
      supid
    , supply
    , supdate
    , supamount
    , lead(supdate) over (partition by supid order by supdate desc) ldate
    , row_number() over (partition by supid order by supdate desc) rn
    from supply
    where
    months_between(supdate,ldate) >= 18
    and
    rn = 1
    Message was edited by: chris227
    extended

  • Select ALV row right after first display

    Hi,
    I want to pre-select specific rows in my ALV already when it`s first displayed. I tried to use method set_selected_rows in the PBO where the ALV object is created, but it did not work. It only worked when I put the method in the PAI.
    Can I select rows of the ALV when it is initially displayed, that is before it`s screen`s PAI is called?
    Thanks.
    Krisz

    Hi
    Its possible to have the rows pre-selected using buttons.
    In PBO, after calling method-set_table_for_first_display
         CALL METHOD cl_grid->get_selected_rows
           IMPORTING
             et_index_rows = tb_row_id[]
    Loop on the internal table whose records are displayed in ALV,
    and set the parameter index in TB_ROW_ID as SY_TABIX.
    endloop.
         CALL METHOD cl_grid->set_selected_rows
           EXPORTING
             it_index_rows = tb_row_id.
    I have tested it and works.
    Please let me know whether it works or not
    BR
    Lavanya

  • Select Records by date?

    Hello,
    I would like to let the last three months in a Bar Chart be indicated. The table has stored a column "DATE_LIST" in which the date for the respective data record is stored. The surface element has the format "MONTH YEAR". So every DATE is just 1st of an Month, e.g., 01.01.2003, 01.02.2003......
    How can i do this?
    Thanks Peter
    Message was edited by:
    PeterB81

    Like This...?
    select *
    from your_table
    where date_olumn > add_months(sysdate,-3)
    If not, please provide sample data and expected o/p...                                                                                                                                                                                                                                                                                                       

  • Form save problem - lose data after first save

    Hi,
    I have used Reader Extensions to permit Adobe Reader to fill in and save a form but find that after one save the rights are lost. Can you tell me what limits rights? Are there features of a form that may result in the rights being removed after a save? The form in question has some automation, for example it allows a user to click a button to reveal more subforms. It loses the save data rights even if the user just opens the form and then saves it. The next time it is opened the save data usage rights have been removed.

    Check the data binding on the field that loses its value. If it says "none", that's the problem. A quick way to check the bindings is to use the bindings tab on the Report pallette. To see the Report pallette, go to (menu)Window-->Report.
    Jared Langdon
    www.jlangdon.ca

  • Not correctly reading serial port data after first cycle

    I set up a VI for serial communication using RS232 with a pressure transducer meter. The pressure readings are in a loop along with a series of calculations in that loop. The readout from the first cycle is correct, but i just see garbage characters on every subsequent cycle. The VI was running fine when the loop was just reading the pressure data and not performing any calculations. What could be the reason for this discrepancy.
    The OS is windows NT and software is Labview 6.1
    Thanks

    Thanks for your response,
    I am using a VISA. The bytes at serial port are fixed, that is for a particular command the response number of bytes is fixed. The read operation in the first cycle (of a loop) is correct but it reads garbage characters for every other cycle. I am using a 9600 baud rate and the meter responds directly in strings, no handshake is used.
    Thanks for the response,
    PS: The computer with the code is not connected to the net, i will need to transfer it to post the code.

  • How to adjust data in first and next pages in sap smart forms ?

    Hello,
    i am creating a purchase order and displaying it in a smartform. I have a main window in which i have a table listing the material details nested with item asscoiated with it. Underneath this table/main window, i have another window containing some 'special instructions'. And underneath this window i have another window which acts as a footer(signatures).
    Now what happens is that when i increase the no of items against a material in purchase order or input too many materials , my table gets cut and goes on to the next page ( which looks bad ).
    according to you what should i do ? or can i calculate or check the number of entries in the table and if they exceed the height of the main window, take the main window or the table to the next page(so that it doesnt get cut)   ??
    help needed ,, thanks....

    Hi,
    If the no. of line items are more then the data has to overflow into the next page. However, if the data is getting cut at the row level, meaning half of the data that belongs to the row is being split into two pages, then you can switch in the PAGE PROTECT mode at the line level.
    This will make sure that row is either completely displayed in the same page or the next page.
    Regards,
    Ravi
    Note : You have quite a few threads open, please mark all the helpful answers and close the threads if the questions are answered

  • Select record from database table

    how to select a record from data-base table for current month in module-pool, i.e if current month is august then records selected should between 1/08/10 to 31/08/10.
    And, i also want to select records for last month i.e if current month is august then records selected should be between 1/07/10 to 31/07/10.
    And one thing more, it should work for every scenario. Like for months are changing then it should work according to that.
    Example: If month changes to October then current month ll be October and last month ll become September.
    Plz help me out.
    Moderator message: you chose a better forum this time, but the question is still too basic to be asked here, please (re)search yourself first, these forums are not catering to beginners.
    locked by: Thomas Zloch on Aug 8, 2010 9:41 PM

    Hi Nishant,
    You can use the option <b>ORDER BY </b> in your SELECT clause.
    This is the SAP Documentation for <b>ORDER BY </b> option.
    <i>Variant 1</i>
    <b>...ORDER BY PRIMARY KEY</b>
    <b>Effect</b>
    Sorts the selected lines in ascending order by the primary key of the database table. This variant is only permitted for SELECT * ....
    <i>Notes</i>
    Since views do not have a primary key, specifying ORDER BY PRIMARY KEY only makes sense with database tables. If, however, you do specify ORDER BY PRIMARY KEY with a view, all fields of the view are sorted in ascending order.
    <i>Variant 2</i>
    <b>ORDER BY f1 ... fn</b>
    <i>Effect</i>
    Sorts the selected records in ascending order by the specified column references f1 ... fn. If a list is also specified in the SELECT clause, the column references f1, ..., fn must appear in this list.
    By supplementing the statement with DESCENDING, you can sort in descending order using any of the fields f1, ..., fn.
    The default sort sequence is ascending order, but you can make this explicit by adding the addition ASCENDING.
    Consider this code this will select the latest 10 records form DB table(Note can use <b>Variant 2</b> for DB tables also.
    REPORT zarun_1.
    DATA : it_mara TYPE STANDARD TABLE OF mara WITH HEADER LINE.
    START-OF-SELECTION.
      SELECT * FROM mara
                INTO TABLE it_mara
                <b>UP TO 10 ROWS                "No of rows you need(give 1 here)
               ORDER BY matnr DESCENDING.    "Specify the Key Fields here.</b>
      LOOP AT it_mara.
        WRITE : / it_mara-matnr,
                  it_mara-mtart.
      ENDLOOP.
    Regards,
    Arun Sambargi.
    Message was edited by: Arun Sambargi

  • Need sql querry for  PreviousYear First Day Same Month And Currentday rec

    Hi ,
    I hAVE TABLE FOR EXAMPLE,
    emp sal Arrivaldate
    111 200 03-mar-2011
    100 200 03-mar-2008
    150 200 06-mar-2012
    170 200 03-mar-2003
    178 200 03-mar-2004
    112 200 12-jun-2012-------------------->For Example THIS IS TABLE WE HAVE LOT OF RECORDS
    I need querry to get based on this condition:Arrival Date is between Previous Year First Day Same Month And Current day.
    Any one help me on this.....

    Hi,
    To get the records between Previous Year First Day Same month to Current day..
    SELECT TRUNC (ADD_MONTHS (SYSDATE, -12), 'MM') AS last_yr_first_date, TRUNC(SYSDATE) AS PRESENT_DATE
      FROM DUAL;Which Outputs to:
    LAST_YR_FIRST_DATE     PRESENT_DATE
    6/1/2011                   6/13/2012When you give TRUNC(sysdate) It will removes the Time part of the SYSDATE.
    For Ex :
    TRUNC(SYSDATE) means that is 6/13/2012 which doesn't give the time part in the query.
    Which takes into account the day start that is from 12:00 A.M to today midnight 11.59 P.M.
    And, One thing is that
    emp sal Arrivaldate
    111 200 03-mar-2011
    100 200 03-mar-2008
    150 200 06-mar-2012
    170 200 03-mar-2003
    178 200 03-mar-2004
    112 200 12-jun-2012The arrivaldate is in Character format so you need to convert to date type as
    SELECT TO_DATE(ARRIVALDATE,'DD-MON-YYYY') from your_table;
    and the comparison can be done as
    SELECT *
      FROM YOUR_TABLE
    WHERE TO_DATE (ARRIVALDATE, 'DD-MON-YYYY')
       AND TRUNC (ADD_MONTHS (SYSDATE, -12), 'MM')
       AND TRUNC (SYSDATE);Good day!!!!!!!!!!!!!!!!!!!!!!!!
    Thanks,
    Shankar

  • How to read data after select multiple record by checkbox,

    hi experts
    i  m using simple report with check box , and itab whcih contain records
    how to read data after select multiple record by checkbox,
    thanks

    Hi Prashant,
       Try using this logic.This Code displays the list with check boxes. When you check a checkbox and press a button say 'Select All' or 'De Select all' or 'Display'. It will read the data of those records.
    DATA :
      fs_flight TYPE type_s_flight,
      fs_flight1 TYPE type_s_flight1.
    * Internal tables to hold Flight  Details                             *
    DATA :
      t_flight LIKE
      STANDARD TABLE
            OF fs_flight,
      t_flight1 LIKE
       STANDARD TABLE
             OF fs_flight1.
    SET PF-STATUS 'SELECT' .
    PERFORM selection.
    PERFORM displaybasic .
    *                      AT USER COMMAND EVENT                          *
    AT USER-COMMAND.
      PERFORM selectall .
    *&      Form  SELECTION
    *      Select query to reteive data from SPFLI table
    *  There are no interface parameters to be passed to this subroutine.
    FORM selection .
      SELECT  carrid                       " Airline Code
              connid                       " Flight Connection Number                  
        FROM  spfli
        INTO TABLE t_flight.
      DESCRIBE TABLE t_flight LINES w_lines .
    ENDFORM.                               " SELECTION
    *&      Form  DISPLAYBASIC
    *      Display the basic list with SPFLI data
    *  There are no interface parameters to be passed to this subroutine.
    FORM displaybasic .
      LOOP AT t_flight INTO fs_flight.
        WRITE :
             w_check AS CHECKBOX,
             w_mark,
             fs_flight-carrid UNDER text-001,
             fs_flight-connid UNDER text-002.
      ENDLOOP.                             " LOOP AT T_FLIGHT..
      CLEAR fs_flight-carrid .
      CLEAR fs_flight-connid.
    ENDFORM.                               " DISPLAYBASIC
    *&      Form  SELECTALL
    *      To check all the checkboxes with a 'selectall' push button
    *  There are no interface parameters to be passed to this subroutine.
    FORM selectall .
      CASE sy-ucomm.
        WHEN 'SELECT_ALL'.
          w_check = 'X'.
          w_line = 4 .
          DO w_lines TIMES.
            READ LINE w_line .
            MODIFY LINE w_line FIELD VALUE w_check .
            ADD 1 TO w_line .
          ENDDO.                           " DO W_LINES TIMES
          CLEAR w_line.
        WHEN 'DESELECTAL'.
          w_check = space.
          w_line = 4 .
          DO w_lines TIMES.
            READ LINE w_line FIELD VALUE w_mark .
            IF w_mark = space .
              MODIFY LINE w_line FIELD VALUE w_check .
            ENDIF.                         " IF W_MARK = SPACE
            ADD 1 TO w_line .
          ENDDO.                           " DO W_LINES TIMES
        WHEN 'DISPLAY'.
    IF sy-lilli BETWEEN 4 AND w_lines .
        DO w_lines TIMES.
          READ LINE w_num FIELD VALUE w_check INTO w_check
                                     fs_flight-carrid INTO fs_flight-carrid
                                     fs_flight-connid INTO fs_flight-connid.
          IF sy-subrc = 0.
            IF w_check = 'X'
              SELECT  carrid
                      connid
                      fldate               " Flight date
                      seatsmax             " Maximum capacity in economy
                      seatsocc             " Occupied seats in economy class
                FROM  sflight
                INTO  TABLE t_flight1
               WHERE  carrid = fs_flight-carrid
                 AND  connid = fs_flight-connid.
              LOOP AT t_flight1 INTO fs_flight1.
                WRITE :
                  / fs_flight-carrid UNDER text-001,
                    fs_flight-connid UNDER text-002,
                    fs_flight1-fldate UNDER text-007,
                    fs_flight1-seatsmax UNDER text-008,
                    fs_flight1-seatsocc UNDER text-009.
              ENDLOOP.
            ENDIF.                         " IF SY-SUBRC = 0
          ENDIF.                           " IF W_CHECK = 'X'.
          ADD 1 TO w_num.
        ENDDO.                             " DO W_LINES TIMES
        CLEAR w_check.
        w_num = 0.
      ELSE .
        MESSAGE 'INVALID CURSOR POSITION ' TYPE 'E' .
      ENDIF.                               " IF SY-LILLI BETWEEN..
    ENDCASE.                             " CASE SY-UCOMM
    ENDFORM.                               " SELECTALL
    Much Regards,
    Amuktha.

  • Hello am using ios 7.0.4 I have a question about messages that it does not show the time of a particular message after first message that I recive form a paricular person so please in the next version change this and with every message show time and date

    hello am using ios 7.0.4 I have a question about messages that it does not show the time of a particular message after first message that I recive form a paricular person so please in the next version change this and with every message show time and date

    Hi,
    How is everything going? Have you checked this issue from OWA? If so, please let me know the result.
    In adition, please also try to use the following powershell commands to check if the assistant has right permissions:
    Get-MailboxFolderPermission -Identity
    CEO’s email address:\Calendar -User assistant’s email address
    Also check with:
    Get-Mailbox -Identity CEO’s mailbox
    | fl *GrantSendOnBehalfTo
    Please let me know the result.
    Best Regards,
    Steve Fan
    Forum Support
    Come back and mark the replies as answers if they help and unmark them if they provide no help.
    If you have any feedback on our support, please click
    here

  • Select records based on first n distinct values of column

    I need to write a query in plsql to select records for first 3 distinct values of a single column (below example, ID )and all the rows for next 3 distinct values of the column and so on till the end of count of distinct values of a column.
    eg:
    ID name age
    1 abc 10
    1 def 20
    2 ghi 10
    2 jkl 20
    2 mno 60
    3 pqr 10
    4 rst 10
    4 tuv 10
    5 vwx 10
    6 xyz 10
    6 hij 10
    7 lmn 10
    so on... (till some count)
    Result should be
    Query 1 should result --->
    ID name age
    1 abc 10
    1 def 20
    2 ghi 10
    2 jkl 20
    2 mno 60
    3 pqr 10
    query 2 should result -->
    4 rst 10
    4 tuv 10
    5 vwx 10
    6 xyz 10
    6 hij 10
    query 3 should result -->
    7 lmn 10
    9 .. ..
    so on..
    How to write a query for this inside a loop.

    Hi,
    So, one group will consist of the lowest id value, the 2nd lowest and the 3rd lowest, reggardless of how many rows are involved. The next group will consist of the 4th lowest id, the 5th lowest and the 6th lowest. To do that, you need to assign numbers 1, 2, 3, 4, 5, 6, ... to the rows in order by id, with all rows having the same id getting the same number, and without skipping any numbers.
    That sounds like a job for the analytic DENSE_RANK function:
    WITH     got_grp_id     AS
         SELECT     id, name, age
         ,     CEIL ( DENSE_RANK () OVER (ORDER BY id)
                   / 3
                   )          AS grp_id
         FROM     table_x
    SELECT     id, name, age
    FROM     got_grp_id
    WHERE     id     = 1     -- or whatever number you want
    ;If you'd care to post CREATE TABLE and INSERT statements for your sample data, then I could test it.
    See the forum FAQ {message:id=9360002}

  • Adobe form displaying data of previous selected records

    Dear All,
    I have created a wd component consisting of 2 views.
    In the first view i am displaying an ALV. When i select a record and click on the alv button, the second view
    gets called which contains an Adobe Form showing the data.
    The problem i am facing is that the record which gets displayed in the adobe form is the one previous selected record and not the current record which i select.
    Kindly give your valuable suggestions .
    Regards,
    Niti

    Hi ,
    Adobe form is just an external media in your case , it has nothing to do with your data.
    Check what data is getting passed to adobe form via debuging .
    check if your getting the selected element .
    You can also post your code here if possible.
    Regards
    Kuldeep

Maybe you are looking for