To get previous day timestamp of a timestamp value in java

Hi,
I have a timestamp variable, say settledTimeStamp which is passed as a runtime argument to a query. I should also send another timestamp variable say previousTimeStamp whose value should be previous day timestamp, ie for settledTimeStamp.
For example,
Todays date= May 9th 2008.
say settledTimeStamp to May 7th 2008.
I should get the timestamp value for previous day to SettleDate i.e May 6th, 2008.
I am showing this as an example because I tried with Calendar options too but it takes current timestamp and gives previous days timestamp which is not the same as I required. Like it returns May 8th as my previousTimeStamp if I work with Calendar options....
Can anyone help me on this?

An object of the Calendar class represents a specific point in time. The fields, such as DAY_OF_MONTH, allow you to access meaningful parts of that specific point in time and use them. Calendar.DAY_OF_MONTH is a field, and it doesn't represent the "current day" or any particular point in time at all. It's used to ask a particular Calendar object what its DAY_OF_MONTH is.
import java.util.Calendar;
public class Test {
     public static void main(String[] args) {
          Calendar cal = Calendar.getInstance();
          cal.setTimeInMillis(99999999999L);
          int year = cal.get(Calendar.YEAR); //cal, what is your YEAR?
          System.out.println(year);
          int dayOfWeek = cal.get(Calendar.DAY_OF_WEEK); //cal, what is your DAY_OF_WEEK?
          System.out.println(dayOfWeek);
          boolean inApril = Calendar.APRIL == cal.get(Calendar.MONTH); //cal, are you in the month of APRIL?
          System.out.println(inApril );
          System.out.println(cal); //cal, tell me all about yourself
}Really, the documentation can do a better job explaining it than I can. Read it. And there are numerous Calendar and Date tutorials all over the internet. Date processing in java is not the easiest thing, so it can take a bit of getting used to, but you will have to read the documentation and write code yourself to understand it.
Oh, and you mark your question as answered and then dispense duke stars to posts you felt were helpful. I don't think people here really care much about them.

Similar Messages

  • How to get previous day of the date

    Hi,
    for a given date I need one day minus as a result date
    my input would be any date
    for example :
    Input Date : 2006-03-22 ( yyyy-mm-dd)
    Output should be : 2006-03-21
    If my input is 1st of April 2006, output i would expect is 31st March 2006
    Please suggest how to achieve this
    Thanks in advance
    Nilesh

    Find below the code to get previous day of the current date
    import java.util.Date;
    import java.text.DateFormat;
    import java.text.SimpleDateFormat;
    import java.util.Calendar;
    public class PreviosDay
    public static void main(String[] args)
    DateFormat dateFormat = new SimpleDateFormat( "MM/dd/yyyy");
    Calendar cl = Calendar.getInstance();
    // you can use a Date object's getTime() method , which is initialiazed
    // to desired date here directly ex: Date dt = new Date("10/10/2004");
    // cl.setTimeInMillis(dt.getTime());
    cl .setTimeInMillis(System.currentTimeMillis());
    cl.add(Calendar.DAY_OF_MONTH, -1);
    System.out.println("Previous date : "+dateFormat.format(
    new Date(cl.getTimeInMillis() ) ) );
    }

  • How to get previous day data if i dont have current day data.

    Hello Gurus,
    I have a stock levels data in ODS. when there is no movements, we are not getting any stocks into ODS. So we have to get previous day data as it is for current day data into another ODS.
    Could you please help me in this regard.
    Thanks in advance,
    Rama

    Rama -    
            0CALDAY can't help us in this scenario .
    Step 1 :
        To do this - You have to add one ZDATE (InfoObject ) to 1st ODS. ZDATE is updated by itself from current date of system  when ever you are loading data to 1st ODS.
    Step 2:
       You have to do full update to 2nd ods.At the selection screen of InfoPackage  (from 1st ODS to 2nd ODS ) you have to write following code for ZDATE.
    pseudo Code:
    1) Select fields "Rec_INSERT","Time stamp","Request Status" and "Request ID"  where ICUBE = ODS1 from table "RSMONICDP"
    2) Populate above selected fields data in INTERNAL TABLE
    3) Sort INTERNAL TABLE by Time stamp .
    4)
         If (Record Count = ' 0 ' for current date in internal table )
         update records from  ODS1 to ODS2 where ZDATE = "yesterday date"
         else
         update records from ODS1 to ODS2 where ZDATE= "today date"
         endif.
    Make sure this is full update not delta update from ODS1 to ODS2
    I am sorry, I m not good in Coding but I am sure if  u use this logic,You can meet your requirement.
    I hope you can understand my logic. Let me know if you have any questions,
    Anesh B .

  • How to get previous days execution time?

    Hello All,
    I have below 3 tables in my Oracle Database --
    1) Table jobs
    Job ID  Job Name
    1      ABC
    2      PQR
    3      XYZ
    2) Table Job_Tasks
    Task_ID   TASK_NAME  Job_ID 
      T1              T_ABC            1
      T2              T_ABE            1
      T3             T_ABD            1
      T4             T_PQS            2
      T5             T_PQT            2
      T6             T_PQU            2
      T7             T_XYA            3
      T8             T_XYZZ           3
      T9             T_XYYA           3
    3) Job_LOG_Table
    JOB_SEQ  JOB_ID  JOB_NAME   START_TIME  END_TIME           STATUS
    1111              1        ABC    06/09/2013 11:00     06/09/2013 13:00   COMPL
    1234              1        ABC    07/09/2013 11:30     07/09/2013 13:30   COMPL
    1235              1        ABC    08/09/2013 11:30     08/09/2013 13:30   COMPL
    1244              1        ABC    09/09/2013 11:00     09/09/2013 13:00   COMPL
    1354              1        ABC    10/09/2013 11:30      10/09/2013 13:30   RUNNING
    Question Is --
       I would like to display the job status from yesterday and from time 20:00 onwards.. ie. it should display the job_SEQ 1354. ( start_time >= (sysdate-1)||'20:00:00') and  also want to disaply previous days execution time for same job (ie. for 9th Sep).
    The result should be --   Job_name PREV_START_TIME, PREV_END_TIME, TODAYS_START_TIME, TODAYS_END_TIME, STATUS
      As I am displaying the jobs from yesterday 20:00 hour onwards.. I am unable to get previous execution time for the same job.
    I tried with Analylitical function LAG  but it's showing PREV_START_TIME.and PREV_END_TIME as BLANK.
    Could you please help me to resolve the issue?
    Thank you in advance.

    As suggessted by Mike,  below is the modification I have done in my sql and I think it's working now....
    I will check for more volume of data and confirm.  --
    select original_sql as
    select w.job_id,
    w.job_name,
    r.start_time,
    r.end_time,
    r.status
    from
      jobs w,
      job_log_table r
    where
      r.job_id=w.job_id
    select job_id,job_name,
    (select start_time from job_log_table j where j.job_id=os.job_id and j.start_time>=sysdate-2 and rownum <2) prev_start_time,
    start_time,
    end_time,
    status
    from Original_sql os
    where
    os.start_time>=to_date(to_char(sysdate-1,'DD/MM/YYYY') || ' 20:00:00','Dd/MM/YYYYHH24:MI:Ss')
    as of now, I am getting the below result --
    job_id,  job_name  prev_start_time,      prev_end_time,            curr_start_time,           curr_end_time,           status 
           1           ABC  09/09/2013 11:30   09/09/2013 13:00      10/09/2013 11:30          10/09/2013 13:30          RUNNING
    Thank you !

  • Need sql querry for getting previous day records only

    Hi ,
    i have a table with following records,
    emp sal date
    111 200 03-mar-2011
    100 200 03-mar-2008
    15 200 06-mar-2012
    17 200 03-mar-2003
    178 200 03-mar-2004
    11 200 11-jun-2012
    i need only previous day records only(11 200 11-jun-2012).can any one help on this query?

    insa wrote:
    Except trun you can use Like operator--
    select * from emp where date like sysdate-1;
    Is it helpful for you?That is most certainly not a helpful answer. the LIKE operator is a string comparison operator and should not be used with dates. Doing so will cause an implicit date to character conversion based on the sessions NLS settings and would be not different to doing:
    select * from emp where to_char(date) = to_char(sysdate-1)... which will cause a lack of index usage, and also not deal with any time component within the date.
    Please ensure you test your answers before posting them. Several people had already given correct answers here with explanations as to why they are better than other methods.

  • How to get previous month data from current month values

    Hi Experts,
    I have made one universe from BW Query in which Fiscal year period is entered in interval.
    I have made a universe from that and want to develop webI reports on top of that.
    In my webI reports, i have used one cross tab. In Rows section i have added Company Code and in Column section i have used Fiscal Year/Period and in Value section i have added Sales Value. I want this value of previous month.
    Requirement:
    Ex.
                            Feb'09          Mar'09     and so on...
    Comp_code1   Sales of Jan'09         Sales of Feb'0f         and so on....
    I am getting this.
    Ex.
                            Feb'09          Mar'09     and so on...
    Comp_code1   Sales of Feb'09         Sales of Mar'09         and so on....
    I hope i have clear my requirements.
    Please help as soon as possible.
    Thanks in Advance,
    Rishit

    Hi Rishit,
    Follow the below steps to get the desired result.
    Step1: Convert your fiscal year period from char to a date in your database or in your designer however its feasible.
    to_date('substr('009.2009',2)','mm.yyyy')
    you will get the result 01 sep 2009
    Step2: Convert this format to 01/09/2009 by using date functions.
    Step3: Create a Detail associated to the 'date' field (typically your fiscal period).
    Step4: Create a cross tab Like : Rows section should have Company Code and in Column section should have 'date'(created detail) and in Value section should be Sales Value.
    you should get the following result.
    01/02/2009 01/03/2009 and so on...
    Comp_code1 Sales of Feb'09 Sales of Mar'09 and so on....
    Step5: Use the following formula in your Column (date) formula bar.
    =(<date>-1)-DayNumberOfMonth(<date>-1)+1
    You will get the following result:
    01/01/2009 01/02/2009 and so on...
    Comp_code1 Sales of Feb'09 Sales of Mar'09 and so on....
    Format the cell according to your reruirement.
    Let me know if you will get any break in the above steps.
    Regards,
    Swati.

  • How to get the day value from the current time?

    Hi,
    I like to write a program that prints out the current time in the formate as "Thu May 3 07:57:02 PDT 2002". Then I want to get the day, time, year and month value out and do some manipulation.
    I know to format the current time, I can use
    SimpleDateFormat formatter
    = new SimpleDateFormat ("EEE MM.dd hh:mm:ss z yyyy");
    Date currentTime_1 = new Date();
    Now how do I get the day, time, year and month value? All the getday(), gettime()..,method have been deprecated. Can anyone provide the answer?
    Thanks.

    Try using Calendar.get(int) and take a look at the constants used to specify the field you are trying to access.

  • How do I set iCal alerts to a specific time the previous day, regardless of their specific time (so I can get an overview of tomorrow)?

    I think it would be incredibly useful to be able to get at, say, 10pm each evening, a pop up overview of the next day's events. I'm hoping for a tick box somewhere to set my default reminder as a specific time on the previous day, in the same way that you can do '15 minutes before'. Currently you can set reminders for a specific time and date, but, entering this for every item – especially if you want them to coincide – is more than slightly tedious. Furthermore, I input a lot of my Calender events on my iPhone (they sync via iCloud), which has no such functionality, rendering this essentially defunct.
    Any ideas?

    apple don't have a version of windows
    only microsoft have windows
    as how one automatate windows to send mails at a time
    googled it for you
    http://www.howtogeek.com/125045/how-to-easily-send-emails-from-the-windows-task- scheduler/
    more options in the search
    https://www.google.dk/search?client=opera&q=automatically+send+email+in+windows& sourceid=opera&ie=UTF-8&oe=UTF-8

  • How to get Last Day of a Previous Month

    Hi all,
    I need to get Last Day of the Previous Month. I am able to get Current Month Last Day using Calendar.getActualMaximum(Calendar.DATE)
    But I need previous Month's Last Day.
    Thanks
    Vamshi.

    Thanks all....
    I have been trying the same and could get it.....
    here is the code for that....
    SimpleDateFormat simpleDate = new SimpleDateFormat("MM/dd/yyyy");
    Calendar calendar = Calendar.getInstance();
    month = calendar.get(Calendar.MONTH);
    //year = calendar.get(Calendar.YEAR);
    calendar.set(Calendar.MONTH, month-1);
    calendar.set(Calendar.DATE, calendar.getActualMaximum(Calendar.DATE));
    //lastDayOfMonth = calendar.getActualMaximum(Calendar.DATE);
    System.out.Println("Previous Month End Date is :: " + simpleDate.format(calendar.getTime()));
    this works....
    thanks for ur replys....

  • Bex Query Get Qty of previous day

    Hello,
    I have a requirement and I'm not sure if it possible to design a bex query for it
    I have the stock data for each date.In my report I need to display the current day stock,previous day stock and the delta.
    The layout should be like below
                   Calendar day  01.01.2009    02.01.2009  03.01.2009 .........
    Stock                          |           200 |            350   |         425  |
    Stock previous day       |           100 |            200   |         350  |
    Delta                           |           100 |            150   |           75  |
    To get the current day stock is simple,it will just get the stock associated with that calendar day but to fetch the previous day stock i'm not sure how to set the fillter.
    Any suggestions please?
    Thank You.
    Edited by: A Pothuneedi on Apr 27, 2009 4:43 PM

    Hi,
    Select Stock Prv Day - Right Click--> Edit- now Find the Time dimension and Select CALDAY and drag drop right side.
    Right click on calday Select Restrict --> Select the variable which created move it to right side and give offset as -1. You will find offset setting above.
    Please do this and let us know if still have any issues.
    Reg
    Pra

  • Could not get Previous Week Day starting today

    I need help  to get PREVIOUS WEEK day starting today.
    Eg:
    Today is 15 / 09 / 2011
    I need Date 08 / 09 / 2011
    Hence both 15th and 08 are Thursday. One is today's thursday and other is previous week thursday.
    Regards

    Warranty on iPhone is not international, but valid only in country of
    original sale. Since you purchased the iPhone in Australia, your warranty
    is valid only in Australia. You must either personally return the iPhone
    to Australia for evaluation and possible replacement or sent it to someone
    in Australia to take into Apple for the evaluation. Apple will not accept
    international shipments for repair nor will Apple ship out of the country
    after replacement.
    Sorry to be the bearer of this news, but it is the way iPhone warranty and
    replacement has always worked.

  • GetCoreResourceModificationDate could not get path to timestamp file

    Porting my InDesign CS5.5 Plugin to InDesign CS6, when I build a debug version of the plugin and deploy it to the  InDesign CS6 Debug version and launch InDesign I get "PlugInData::GetCoreResourceModificationDate could not get path to timestamp file: C:\Program Files (x86)\Adobe\Adobe InDesign CS6 Debug\Plug-ins\SCC\(SCCINDDEXTRACTION V7.1.0.17 FOR CS6 Resources)\timestamp.idrc" which suggests that InDesign is expecting to find a "timestamp.idrc" file in the root of my plugin's resources subfolder. I have searched the sdk and google and have found nothing about a timestamp resource for InDesign plugins. Is my plugin resource (.rc or .fr file) supposed to include some kind of timestamp that would cause the resource compiler to generate a timestamp.idrc file?

    OK, I fixed this, but not sure how.
    I think the cache was corrupt.

  • Howto to get the year timestamp in syslog and logadm files

    5.10 Generic_141414-10 sun4u sparc
    Howto to get the year timestamp in syslog and logadm
    We have to keep logs files for a long time, I was exploring logs in /var/adm/secure and noticed that log files over a year old did not have a year time stamp, they are in this format:
    Nov 12 09:09:16
    And on the face of it. /varlog/syslog is the same, I thought no problem, there will be something in syslog.conf or logadm.conf I change and it will be fixed, but I cannot find any options to change this, how do I get the year in my log files?
    The "date" command does output the year:
    Friday, September 14, 2012  7:57:36 AM

    My guess is that the fields in a message logged by syslog are fixed, so you can't add a field to it.
    The reason for this is simply that there might be other applications parsing your syslog messages, or there might be other systems syslogging to your system, and that would break if you would add fields.
    The easiest workaround is probably to keep better track of your logs by either implementing an annual rotation of them from crontab, or log the date using the "logger" command on a regular basis.
    A third option would be to look at syslog-ng or rsyslog, which is more flexible when it comes to storing logs, and among other things can store them into a SQL db..
    .7/M.

  • Getting the date for the previous day

    How do I get the previous day's date with LabView 7.0? Is there a built in function that will allow me to do this (taking into account the number of days in a month, leap years etc) or do I have to write my own vi?
    Thank you,
    KB

    All you have to do is use the Get Date/Time in Seconds and then subtract the number of seconds in a day. The result is a time stamp that should account for everything.
    Attachments:
    Subtract_Day.jpg ‏4 KB

  • Get the timestamp value in the form of array of 8 bytes, whileretrieving da

    3) How we can get the timestamp value in the form of array of 8 bytes, while retrieving the data?
    4.) How we can pass the 8 byte array to stored procedure? What will the data type of the parameter?

    duplicate post:
    timestamp value in the form of array of 8 bytes

Maybe you are looking for

  • Consignment stock replenishment via idoc

    We are setting up a scenario, where we receive oderCreate idocs (CIDX format) into our XI system which should trigger a stock replenishment from the producing plant into the customer consignment stock. As the delivery has to be created with reference

  • Sun cluster failed when switching, mount /global/ I/O error .

    Hi all, I am having a problem during switching two Sun Cluster nodes. Environment: Two nodes with Solaris 8 (Generic_117350-27), 2 Sun D2 arrays & Vxvm 3.2 and Sun Cluster 3.0. Porblem description: scswitch failed , then scshutdown and boot up the bo

  • ECC 6.0 (backend) upgrade

    Hi all We have recently upgraded to BI 7.0 and using only 3.x datasource .   We are in the process of upgrading our backend R/3 4.6c to ECC6.0. Question:  Is there anything that we should be looking out for when we switched to ECC 6.0 on the backend?

  • DB Connect Procedure

    hi collegues, Some one Please give me the complete procedure of DB connect(Oracle Database)  with all details like, 1. Where should the DB client should exist 2. advantages of DB connect Please send me the Details at   [email protected] Thanks in adv

  • CS5.5 trial publish ipa file issue

    I'm using cs5.5 trial version. When I complete all the certificate and provisioning file locate in the publish entry and press publish but no ipa file being created. only a folder named "AOTBuildOutput720866926256539637.tmp". Does anyone know what's