Force date to be stored as month 01, year

I have a date field in a report.
When I input or edit, a datepicker calender pops up and the user click on a date.
What I like to do is when the user pick on any date, the database stored as the 1st of the month.
So no matter what the date picked, the data captured is month 01, year.
Is there a way to do this?
Thanks.

Hi,
Maybe you could set up an insert/update trigger on your table.
Something like this
CREATE or REPLACE TRIGGER trigger_name
BEFORE INSERT OR UPDATE
    ON table_name
    [ FOR EACH ROW ]
DECLARE
v_Month VARCHAR2(20);
v_Year VARCHAR2(4);
BEGIN
  v_Month := TO_CHAR(:new.date_column, 'Month');
  v_Year := TO_CHAR(:new.date_column, 'YYYY');
  :new.date_column:= TO_DATE (v_Month|| ' 01 ' || v_Year, 'Month DD YYYY');
EXCEPTION
    WHEN ...
    -- exception handling
END;--
Paulo Vale
http://apex-notes.blogspot.com

Similar Messages

  • UIX 2.1.21: Date OnBlurValidator automatically add current month or year?

    Would be nice if the OnBlurValidator for a UIX Date field could automatically add a missing month or year.
    e.g. Format dd.mm.yyyy
    When the user enters 01.01. the current year could be added automatically.
    Or when the users only enters 01. the current month and year could be added.
    Would be a nice feature additionally to the already existing lenient-date-formats = true.
    Really great would be to allow entering values like "now" / ".", "yesterday" / "-" or "tomorrow" / "+" that are evaluated to the according dates (of course internationalized).
    Thanks, Markus

    hey mill1640,
    Did you ever get your iPhone to register with iTunes? I just upgraded as well to Snow Leopard, and my my isn't recognized at all also.
    If you did get this resolved, I would appreciate a little suggestion in the right direction.
    Many thanks,
    Josh

  • Date must be truncated to month and year

    Hi,
    I have a date field
    after the user gives F4 help I need to truncate the date , i.e I want only month and year
    For Ex.
    If the user selects as 12/12/2009
    I must display as 12/2009
    How can It be done?

    Hi,
    go thru this threads
    Re: Date validation and conversion
    Re: Is DD/MM/YYYY supported in webdynpro for abap application
    it might provide you some guidance

  • Phpmysql server behaviour (How to get date from dropdown list day & month)

    Hi,
    Appreciate if someone can help me on this. I already create form and in my form there is date selector to select day,month and year. But how to use insert record funtion to get the date as below.
    thanks.
    <form id="form1" name="form1" method="post" action="">
      <table width="60%" border="0" align="center" cellpadding="3" cellspacing="3">
        <tr>
          <td width="85">Date</td>
          <td width="4">:</td>
          <td width="381"><input name="name" type="hidden" id="name" value="<?php echo $user ?>" />
            <input name="department" type="hidden" id="department" value="<?php echo $department ?>" />
            <select name="day" id="day" >
              <option value='01'>01</option>
              <option value='02'>02</option>
              <option value='03'>03</option>
              <option value='04'>04</option>
              <option value='05'>05</option>
              <option value='06'>06</option>
              <option value='07'>07</option>
              <option value='08'>08</option>
              <option value='09'>09</option>
              <option value='10'>10</option>
              <option value='11'>11</option>
              <option value='12'>12</option>
              <option value='13'>13</option>
              <option value='14'>14</option>
              <option value='15'>15</option>
              <option value='16'>16</option>
              <option value='17'>17</option>
              <option value='18'>18</option>
              <option value='19'>19</option>
              <option value='20'>20</option>
              <option value='21'>21</option>
              <option value='22'>22</option>
              <option value='23'>23</option>
              <option value='24'>24</option>
              <option value='25'>25</option>
              <option value='26'>26</option>
              <option value='27'>27</option>
              <option value='28'>28</option>
              <option value='29'>29</option>
              <option value='30'>30</option>
              <option value='31'>31</option>
            </select>
            <select name="month" value=''>
    Select Month           
              <option value='01'>January</option>
              <option value='02'>February</option>
              <option value='03'>March</option>
              <option value='04'>April</option>
              <option value='05'>May</option>
              <option value='06'>June</option>
              <option value='07'>July</option>
              <option value='08'>August</option>
              <option value='09'>September</option>
              <option value='10'>October</option>
              <option value='11'>November</option>
              <option value='12'>December</option>
            </select>
            <input type="text" name="year" size="4" value="2011" />
            <label for="date"></label>
            <input type="hidden" name="date" id="date" /></td>
        </tr>
        <tr>
          <td>Start Time</td>
          <td>:</td>
          <td><select name="start_time" id="start_time" >
            <option value="8:45">8:45 AM</option>
            <option value="9:00">9:00 AM</option>
            <option value="9:30">9:30 AM</option>
            <option value="10:00">10:00 AM</option>
            <option value="10:30">10:30 AM</option>
            <option value="11:00">11:00 AM</option>
            <option value="11:30">11:30 AM</option>
            <option value="12:00">12:00 PM</option>
            <option value="12:30">12:30 PM</option>
            <option value="13:00">1:00 PM</option>
            <option value="13:30">1:30 PM</option>
            <option value="14:00">2:00 PM</option>
            <option value="14:30">2:30 PM</option>
            <option value="15:00">3:00 PM</option>
            <option value="15:30">3:30 PM</option>
            <option value="16:00">4:00 PM</option>
            <option value="16:30">4:30 PM</option>
            <option value="17:00">5:00 PM</option>
            <option value="17:45">5:45 PM</option>
          </select></td>
        </tr>
        <tr>
          <td colspan="3" align="center"><input type="submit" name="button" id="button" value="Submit" /></td>
        </tr>
      </table>
    </form>

    kelah_merah wrote:
    ... but I have problem on edit the records. How to get the dropdownlist display the current day,month and year
    I *knew* you´re going to ask this question
    The attached screenshot "screen_update_query" shows how to...
    a) utilize some of MySQL´s Date and Time Functions to extract the day, month and year from a datetime column (here named "col_datetime")
    b) extract the hh:mm via a DATE_FORMAT pattern
    All four information units would be pretty much useless without defining a Column Alias (e.g. AS day)
    The second screenshots shows how to tie the values of one of your dynamic lists (e.g. the list of days) to the respective Column Alias by using the "select value equal to" feature.
    That´s it !

  • Data stored by month, needs chnaging to store by day in cube.

    Hello All,
    I am reporting on HR data.  Data is stored by month in the cube.  So for a given year an employee is likely to have 12 records in the cube (if there where no changes to the record).  A request has come in to store data by day (so an employee would have a minimum of 365 records for a given year).  How would I go about this?
    Any help appreciated.
    Thanks,
    Nick.

    From what I understand, the existing CALDAY field is not storing the required information.
    In this case, you will need to reload the entire data from the source system to load the proper data. As you say your DSO and Cube already have the CALDAY fields, you may not have to redesign but I think a reload is essential (assuming you source system has all the required info).
    And you have the 0CALDAY field as a data field in the DSO? Yes changing it to a key field might help, but for this you would first need to delete all the data from the DSO.
    Sita.
    Edited by: Sita Pulavarti on Jun 4, 2009 12:27 PM

  • Parameter for Last Week, Last Month & Last Year from the current Date

    I have a crystal report that has a StartDate & EndDate parameters from the stored procedure that I am calling. Now i got a new requirement saying that my user wants a drop-down parameter in which they need to be able to select last week (Sunday to Saturday), last month, last year instead of manually selecting start date and end date parameters? Can anyone please explain me how to do this?
    (FYI, I am using Crystal 2008)

    Hi Naveen,
    You'll need to handle the logic in the Stored Proc's where clause.
    If you're using oracle, I have something like this in the Stored Proc's where clause for our reports:
    Where {Date_Field} Between
    Decode('{?Relative Date}',
    'Yesterday', sysdate - 1,
    'Last Week', Tunc(sysdate, 'IW')-7)
    AND
    Decode('{?Relative Date}',
    'Yesterday', sysdate,
    'Last Week', Tunc(sysdate, 'IW'))
    where 'Relative Date' is a prompt in the Stored Proc and 'yesterday'. 'last week' are the 'static values' in the prompt.
    -Abhilash

  • Verizon OUTRAGEOUS with forced data plans

    I've used Palm products since the pilot. I've had a centro for 2 yrs with verizon...now I want to upgrade to Palm Pre 2, but verizon is forcing me to buy a $30/month data plan that I don't want and will never use. I love my palm devices for reasons other than internet access. If Verizon doesn't change this policy, I'll have to abandon palm and go with another carrier. Isn't Palm losing sales becaue of verizon's greed? They should put pressure on Verizon to abandon this outrageous, greedy tactic to abuse their customers.
    Post relates to: Centro (Verizon)

    Contact the FCC immediately and file an informal complaint.  As a communication company, Verizon should never by permitted by the federal government to deny internet access by its VZAccess Manager firewall and unreasonable charges.  You can find the FCC information online very easily.  Fill out the PDF and submit it.  The more of us who do that, the more responsive the federal agency will be to force Verizon to reverse its predatory scheme.

  • How do I manage dates in a stored procedure

    Hey folks,
    I have a table like this:
    STUDENT
    ID INT
    NAME VARCHAR
    REGISTRATION_DATE DATETIME
    create table student (ID int, NAME varchar, REGISTRATION_DATE datetime)
    Insert into student (ID, NAME, REGISTRATION_DATE)
    values
    (1, 'NAME1', '2014-11-10 06:00:00.000'),
    (2, 'NAME2', '2014-11-11 06:00:00.000'),
    (3, 'NAME3', '2014-11-12 06:00:00.000'),
    (4, 'NAME4', '2014-11-13 06:00:00.000'),
    (5, 'NAME5', '2014-11-14 06:00:00.000')
    I have the following store procedure
    CREATE PROCEDURE TRGetMsgTksByBIdDIdPIdAMsreDte
    @REGISTRATION_DATE DATETIME = NULL
    AS
    SET NOCOUNT ON
    SELECT *
    FROM STUDENT
    WHERE REGISTRATION_DATE = @REGISTRATION_DATE
    RETURN 0
    GO
    My problem has to do with date formats and specifically with localizations (sometimes it is saved as MM-DD-YY, others DD-MM-YY, and it does not correspond with the parameter. How can I solve this problem WITHOUT having to apply a format conversion inside
    the WHERE clause? (because when I use a function inside the WHERE, the index created for this column is invalidated and the query takes longer and longer when the DB gets bigger and bigger)
    Thanks,
    Marco

    Hello Marco,
    What is important here is the source of your table's data.  When loading the table with data, your source date values must have a clean, consistent format.  
    For example, if the following two rows represent December 7th, depending on your SQL Server installation / localization, only ONE row will be correct.  The other will be inserted as July 12th.  
    INSERT INTO student (ID, NAME, REGISTRATION_DATE)
    VALUES
    (1, 'Name1', '12/7/2014'),
    (2, 'Name2', '7/12/2014')
    In other cases, the INSERT statement may fail altogether because the date string won't "fit" the localization settings.  For example "25/12/2014" won't fit into a USA-localized SQL Server (there is no such thing as month 25).  "US
    English" is SQL Server's default localization, by the way, and requires dates to be entered with any variation of "month/day/year," or better, in the international format "year/month/day."
    Once your data is cleanly loaded into the table, you can use various string formats in your stored procedure's input parameter, but keep in mind your SQL Server's localization.  All of the following execution statements will work for a query of December
    7th on a US SQL Server installation:
    exec TRGetMsgTksByBIdDIdPIdAMsreDte '12/7/2014'
    exec TRGetMsgTksByBIdDIdPIdAMsreDte '2014-12-7'
    exec TRGetMsgTksByBIdDIdPIdAMsreDte 'December 7, 2014'
    TIP:
    Be careful when querying fields with the "datetime" format.  In your stored procedure, records in the table might be filtered out if they include time information, and if your input parameter fails to specify the exact time.
    A better way might be to change your input parameter datatype to "date" instead of "datetime," then inside the stored procedure, transfer the original input parameter value to start and end datetimes to match the table's datatype.
    Example:
    CREATE PROCEDURE TRGetMsgTksByBIdDIdPIdAMsreDte
    @REGISTRATION_DATE DATE
    AS
    SET NOCOUNT ON
    DECLARE @DATETIME_START DateTime,
    @DATETIME_CUTOFF DateTime
    SELECT @DATETIME_START = @REGISTRATION_DATE -- SQL Server will implicitly expand the input's "date" format into "datetime" type representing midnight of the given date.
    SELECT @DATETIME_CUTOFF = DATEADD(day, 1, @REGISTRATION_DATE) -- the cutoff for the next day
    SELECT *
    FROM STUDENT
    WHERE REGISTRATION_DATE >= @DATETIME_START
    AND REGISTRATION_DATE < @DATETIME_CUTOFF
    RETURN 0
    GO
    The above code will ensure that any index on "REGISTRATION_DATE" is being used (field REGISTRATION_DATE and @DATETIME_START, @DATETIME_CUTOFF are of the same datatype).  The above code will also ensure that if records are stored with time
    information (eg. '12/7/2014 10:30:00'), that they don't get filtered out when the input parameter @REGISTRATION_DATE = '12/7/2014' (implicitly midnight).
    Hope this helps.
    Tuan

  • Function to find the Last Date of Month One Year Ago - RETURNS ERROR

    I've written sql code which takes a date and finds the Last Day of the Month one year ago. For example,  it takes the date '2015-04-17' and returns the date '2014-04-30'. The code works fine in a query. Now I'm trying to turn this into a function. However,
    when I try to create the function I get the error:
    Operand type clash: date is incompatible with int
    Why is this error being returned?
    Here is my function:
    CREATE FUNCTION dbo.zEOM_LY_D(@Input Date)
           RETURNS date
    AS
    BEGIN;
      DECLARE @Result date;
      SET @Result =  convert(DATE, DATEADD(s,-1,DATEADD(mm, DATEDIFF(m,0,dateadd(m, -11, @Input)+1),0)),101)
        RETURN @Result;
    END;
    Thanks for any help you can give.
                     

    Stan,
    Thanks very much- that does the trick. I should have said I am using SQL 2008 so EOMONTH is not available to me. I still don't get why I got an error though, since I was treating a date like a date and not like an int.
    Thanks, John
    I think i found the issue but i do not know why it is causing the issue. i think may be the way dates are treated/stored internally..i think dates are stored as no of days after 0001/01/01 but cannot see how this cwould effect..may be somebody else can through
    some light..... 
    if you make it as datetime it will work,
    if you leave it as date - eliminate adding 1...  you should prefer to use dateadd to add/substract dates.
    try this to understand..
    --removed the +1 in the code
    declare @input date
    set @input ='20150503'
    select
    convert(DATE, DATEADD(s,-1,DATEADD(mm,DATEDIFF(m,0,dateadd(m, -11, @Input)),0)),101)
    go
    --made the datatype as datetime
    declare @input datetime
    set @input ='20150503'
    select
    convert(DATE, DATEADD(s,-1,DATEADD(mm,DATEDIFF(m,0,dateadd(m, -11, @Input)+1),0)),101)
    Hope it Helps!!

  • Loop through month and year till date while using a merge statement

    Hello Guys,
    I have 2 tables with the following datas in them:-
    Company
    CompanyId CompanyName
    1                 Company1
    2                 Company2
    3                 Company3
    Employees
    EmployeeId EmployeeName CompanyId StartDate
    1                  Employee1        1                 12/21/2011
    2                  Employee2        1                 01/20/2012
    3                  Employee3        2                 03/23/2012
    4                  Employee4        2                 07/15/2012
    5                  Employee5        2                 01/20/2013
    6                  Employee6        3                 12/17/2013
    Now i want to check, How many people were recruited in the team in the specified month and year? I have the storage table as follows:-
    RecruiterIndicator
    CompanyId Year Month EmployeeRecruited
    1                 2011 12      1
    1                 2012 1        1
    2                 2012 3        1
    2                 2012 7        1
    2                 2013 1        1
    3                 2013 12      1
    This should be a merge stored procedure that should update the data if it is present for the same month year and company and insert if that is not present?
    Please help me with this
    Thanks
    Abhishek

    It's not really clear where the merge to come into play. To get the RecruiterIndicator table from Employess, this query should do:
    SELECT CompanyId, Year(StartDate), Month(StartDate), COUNT(*)
    FROM   Employees
    GROUP  BY CompanyId, Year(StartDate), Month(StartDate)
    Erland Sommarskog, SQL Server MVP, [email protected]

  • Forcing Dates

    I'm after an applescript that will allow me to force dates that fall on a weekend back to a weekday. For example we have a recurring event that happens on the 7th of every month, however if the 7th falls on a Saturday we need to force it to the previous Friday, and if the 7th falls on a Sunday we need to move it forward to the next Monday.
    Does anyone know how to do this or even if it is possible? We're using iCal 1.5.5 on Mac OS X 10.3.9.

    If you prefer the short answer: No. The longer answer is a good bit longer but gets you no further.
    It SHOULD be possible, but I don't think it is.
    Applescript won't do it for you. You may not be aware that setting up a recurring event puts only a single event in your calendar file. Every time iCal displays a window with a time frame it calculates which recurring events should be displayed, and displays them. If you modify one of the recurrences iCal makes a copy of the event with the changes and saves it as a detached recurrence. Applescript doesn't know how to make a detached recurrence. Indeed, Applescript has to start with the first occurrence and work forward, parsing the recurrence details, to find whether there is a recurrence in the current time frame. It can be done in simple cases. This is not a simple case.
    iCal's interface for setting recurrences does not allow you to set all the possibilities that it can handle. For example, you can't set a recurrence on the last day of the month, but if you have one, iCal will properly display it. The easiest way of "fooling" iCal for such things is to make a close approximation to what you want, drag it to the desktop, delete it in iCal, edit the desktop copy with TextEdit (or similar) to get the correct RRULE (recurrence rule) then drop the edited file back on to iCal.
    I think (and here I would welcome correction from an expert!) that editing the rule to
    RRULE:FREQ=MONTHLY;INTERVAL=1;BYDAY=MO,TU,WE,TH,FR;BYMONTHDAY=7,8,6;BYSETPOS=1
    should work, if iCal was fully compliant with the calendar specification - but there are certainly instances where iCal is not fully compliant, and either this is one of them, or I am not correctly interpreting the standard - or both!
    AK

  • Is there any way of dragging and dropping an iCal event showing in week view across to a date in the left sidebar monthly calendar?

    Hi, Im not a frequent forum poster, as most of my questions can be found already answered on them!
    This is a question Ive had for a long time and it amazes me that no-one else seems to ask it. I check at each OS upgrade but its never there...
    Is there any way of dragging and dropping an iCal event showing in week view across to a date in the left sidebar monthly calendar?
    I was able to do this years ago in MS Outlook, and utilized it all the time when I needed to push things back, now I have to open the event and select an new date in the drop-down calendar for each & every event I want to move to a new month at the end of the month.
    If its definitely not possible, how to you ask apple to consider including it - it doesnt seem like a particularly difficult task.
    Thankyou
    Andrew.

    Andrew,
    Is there any way of dragging and dropping an iCal event showing in week view across to a date in the left sidebar monthly calendar?
    No, but you can use cut/paste. Cut (⌘X) the event, then click on the week where you want to move the event, and Paste (⌘V).
    If you have a suggestion for Apple to change that method use: Apple - Mac OS X - Feedback.

  • How to get Week,Month and Year details from a date column

    Hi frenz,
    I've a column like tran_date which is a date column..... I need the next week details based on this column and so on...
    I need month and year details as well based on this tran_date column.... can any one tell me how...
    Thanks in advance

    My example for objects:
    create or replace type date_object as object
      centure number,
      year    number,
      month   number,
      day     number,
      hour    number,
      minute  number,
      second  number,
      daypart number,
      week    number,
      constructor function date_object(p_dt date)
        return SELF as result
    create or replace type body date_object is
      constructor function date_object(p_dt date)
        return SELF as result
      as
      begin
        SELF.centure:= trunc(to_char(p_dt,'YYYY')/100);
        SELF.year:=    to_char(p_dt,'YYYY');
        SELF.month:=   to_char(p_dt,'MM');
        SELF.day:=     to_char(p_dt,'DD');
        SELF.hour:=    to_char(p_dt,'HH24');
        SELF.minute:=  to_char(p_dt,'MI');
        SELF.second:=  to_char(p_dt,'SS');
        SELF.daypart:= p_dt-trunc(p_dt,'DD');
        SELF.week:=    to_char(p_dt,'IW');
        return;
      end;
    end;
    select date_object(sysdate),
           date_object(sysdate).year
    from dual;Regards,
    Sayan M.

  • Expression - First date and last date of current month, current year

    Hi
    I need to have 2 ssrs expression as I can use  as default parameters in my report where I can -  out from my Time dimension, get the
    first date of the current, current year - and one where I get last date, current month, current year.
    My data source is a SSAS cube and my timedimension is structured like this:
    [Time].[Days].&[2009-01-16T00:00:00]
    Any suggestions how to solve this ?

    Hi ,
    You can use below in Default Values in ssrs ;
    for first Day of current month and year
    ="[Time].[Days].&[" +Format(dateadd("m",0,dateserial(year(Today),month(Today),1)), "yyyy-MM-dd")+"T00:00:00]"
    output will be ;
    [Time].[Days].&[2014-09-01T00:00:00]
    For last day of current month and year
    ="[Time].[Days].&[" +Format(DateSerial(Year(Now()), Month(Now()), "1").AddMonths(1).AddDays(-1), "yyyy-MM-dd")+"T00:00:00]"
    output will be ;
    [Time].[Days].&[2014-09-30T00:00:00]
    Please correct me if I misunderstood your requirement.
    Thanks
    Please Mark This As Answer or vote for Helpful Post if this helps you to solve your question/problem.

  • How to view the returned data from a stored procedure in TOAD?

    Hi,
    I created ref cursor in the stored procedure to return data. The stored procedure works fine, just want to view the result in TOAD. The BEGIN... EXEC... END can execute the stored procedure, but how to make the result display?
    Thanks!

    Right click the editor and choose
    "Prompt For Substitution Variables".
    Run for example the following code:
    DECLARE
    PROCEDURE p (cur OUT sys_refcursor)
    AS
    BEGIN
    OPEN cur FOR
    SELECT *
    FROM DUAL;
    END p;
    BEGIN
    p (:cur);
    END;
    The result will display in Toad's Data Grid!
    Regards Michael

Maybe you are looking for

  • Song dissapeared from my iPhone and iTunes account

    I recently purchased an Album for my kids (Madagascar 2) and have been listening to it near daily on my iPhone. There is one song in particular that they love (The Traveling Song) that could only be purchased by buying the entire album. For some reas

  • Hibernate+Spring+Structs HTTP 404 Error

    Hey,i am a new here.and a new of Java programming.I have met some problems when i begin to study this. And here is my problem . Java codes: HTTP Status 404 - Servlet action is not available type Status report message Servlet action is not available d

  • Slow/Choppy SWF Animation When View Online

    When I view an swf file from my hard drive, the animation is smooth and snappy (a good thing). After I publish the file and view it online (with the same computer), sometimes it is noticeably slower and choppy. I don't know a great deal about what Fl

  • Alert Message displayed according to WebService response

    I've created and used a Web Service in my VC application which simply send a mail. This Web Service returns a boolean response which indicates if the mail has been correctly sent. I want to inform the user accordingly with an alert message. If the re

  • Is it possible to turn off the infrared emitter without closing the sensor

    Hi, The Kinect v1 SDK had a function ForceInfraredEmitterOff(), which could be called to turn off the infrared emitter without having to close the Kinect. This was very useful for applications using multiple Kinects as it provided an easy way of prev