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() ) ) );
}
Similar Messages
-
How to get maximal value from the data/class for show in Map legend
I make WAD report that using Map Web Item.
I devide to four (4) classes for legend (Generate_Breaks).
I want to change default value for the class by javascript and for this,
I need to get maximal value from the class.
How to get maximal value from the data/class.
please give me solution for my problem.
Many Thx
Eddy Utomouse this to get the following End_date
<?following-sibling::../END_DATE?>
Try this
<?for-each:/ROOT/ROW?>
==================
Current StartDate <?START_DATE?>
Current End Date <?END_DATE?>
Next Start Date <?following-sibling::ROW/END_DATE?>
Previous End Date <?preceding-sibling::ROW[1]/END_DATE?>
================
<?end for-each?>
o/p
==================
Current StartDate 01-01-1980
Current End Date 01-01-1988
Next Start Date 01-01-1990
Previous End Date
================
==================
Current StartDate 01-01-1988
Current End Date 01-01-1990
Next Start Date 01-01-2005
Previous End Date 01-01-1988
================
==================
Current StartDate 01-01-2000
Current End Date 01-01-2005
Next Start Date
Previous End Date 01 -
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,
RamaRama -
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 first day of the month by the given date?
Now, is there function in CRM system that can get the first day of the month ?
for example:
input date is 2007/12/12, then return 2007/12/01 (the first day of month).
Thank you~Hi ping,
data: w_date type sy-datum ,
w_temp(2) type c.
w_date = '20071212'.
w_temp = w_date+6(2).
w_temp = w_temp - 1.
w_date = w_date - w_temp.
write / w_date.
Plz Reward if useful,
Mahi. -
How to - get first DAY of the month from the date ?
Hi
pls helphi,
data : DAYNR LIKE HRVSCHED-DAYNR,
DAYTXT LIKE HRVSCHED-DAYTXT.
data langu like sy-langu value 'EN'.
Parameters PDATE LIKE SY-DATUM.
PDATE+6(02) = '01'.
CALL FUNCTION 'RH_GET_DATE_DAYNAME'
EXPORTING
LANGU = LANGU
DATE = PDATE
CALID =
IMPORTING
DAYNR = DAYNR
DAYTXT = DAYTXT
DAYFREE =
EXCEPTIONS
NO_LANGU = 1
NO_DATE = 2
NO_DAYTXT_FOR_LANGU = 3
INVALID_DATE = 4
OTHERS = 5
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
WRITE :/ PDATE, DAYNR, DAYTXT.
(OR)
Try..
DATA:DAYNR LIKE HRVSCHED-DAYNR,
DAYTXT LIKE HRVSCHED-DAYTXT,
DAYFREE LIKE HRVSCHED-NODAY.
DATA:LANGU LIKE SY-LANGU ,
DATE LIKE SY-DATUM,
CALID LIKE P1027-CALID VALUE 'US'.
date = sy-datum.
date+6(2) = 01. "----->to get the first day .
*first day of the month
write:/ 'First date of the month', date.
*Day name
CALL FUNCTION 'RH_GET_DATE_DAYNAME'
EXPORTING
langu = SY-LANGU
date = DATE
CALID = CALID
IMPORTING
DAYNR = DAYNR
DAYTXT = DAYTXT
DAYFREE = DAYFREE
EXCEPTIONS
NO_LANGU = 1
NO_DATE = 2
NO_DAYTXT_FOR_LANGU = 3
INVALID_DATE = 4
OTHERS = 5
IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
WRITE:/ DAYTXT.
Don't forget to reward if useful.... -
How to get last day of the year
Hi All ,
Thanks in advance ...
How will I get the last day of the year as I am passing date at run time .
I can manage to get first day of year by
SELECT TRUNC(SYSDATE,'YEAR') AS FDAY_YEAR
from dual
Thanks in advance
Regards
Sachin1* select ADD_MONTHS(trunc(sysdate,'yyyy'),12)-1 dd from dual
SQL> /
DD
31-DEC-2010 -
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 ! -
How to get previous values based on date filters
Hi
i have two fields gldate and startdate
gldate values are like 1/31/2011,2/28/2011,3/31/2011,4/30/2011,5/31/2011 ...
startdate values 1/1/2011,2/1/2011,3/1/2011,4/1/2011,5/1/2011 ...
i need a condition like gldate<startdate
if startdate is 11/1/2011 then i get all the values before 11/1/2011 values
im using filter for date filed
let us filter values is startdate--11/1/2011 and gldate is 11/30/2011 but that cond falls
how to get this condition
plz its urgent to meHi
i have two fields gldate and startdate
gldate values are like 1/31/2011,2/28/2011,3/31/2011,4/30/2011,5/31/2011 ...
startdate values 1/1/2011,2/1/2011,3/1/2011,4/1/2011,5/1/2011 ...
i need a condition like gldate<startdate
if startdate is 11/1/2011 then i get all the values before 11/1/2011 values
im using filter for date filed
let us filter values is startdate--11/1/2011 and gldate is 11/30/2011 but that cond falls
how to get this condition
plz its urgent to me -
How to get list of all the dates between two dates
Hi, Can anybody please help me ..
I have two dates in string format ("dd/MM/yyyy).I need to get all the dates in between these two dates.How can I do thin in java
Thanks in advanceLook at classes Calendar and SimpleDateFormat.
And get your abstraction straight: you don't have two dates. You have two Strings that represent a date. To use them, you have to convert them to Date objects first with SDF. -
How to get day of the date in Arabic
Hi All,
Can any one please let me know how we can get the DAY of the date in arabic . for english i know that if we write the below command we will get the day if the date . i need the similar kind of thing for arabic
select to_char(sysdate,'DAY') from dual
thanks in advance
regards
VickyThe code you've posted will retrieve the DAY in Arabic so long as you set NLS_LANGUAGE:
alter session set nls_language=ARABIC;
select to_char(sysdate, 'DAY')
from dual;
الثلاثاء -
How to get same day of a month in every year in the DB ( To update a flag )
Hi,
I am trying to formulate an update query for a flag table in our database which contains dates, and flag columns. Currently the system have dates for the next ten years. The flags are updated with values 0 or 1 if a particular date falls under the required criteria.
I need to update flag column for the same day of the month in every year. e.g. 2nd Sunday of October. The value should be updated to all years in the table. Currently I am using the following query to update the current year.
UPDATE FILTERCALENDAR SET YEAR_WINDOW=1 WHERE c_date = NEXT_DAY( TO_DATE('OCT-2013','MON-YYYY'), 'SUNDAY') + (2-1)*7;
and for next year Like
UPDATE FILTERCALENDAR SET YEAR_WINDOW=1 WHERE c_date = add_months(NEXT_DAY( TO_DATE('OCT-2013','MON-YYYY'), 'SUNDAY') + (2-1)*7,+12)-1;
This is not an excellent way to do it as it does not take care of leap years and it does not scan and update values in the whole table for all years correctly.
Can any one help me to resolve this please.Hi,
user10903866 wrote:
Hi,
I am trying to formulate an update query for a flag table in our database which contains dates, and flag columns. Currently the system have dates for the next ten years. The flags are updated with values 0 or 1 if a particular date falls under the required criteria.
I need to update flag column for the same day of the month in every year. e.g. 2nd Sunday of October. The value should be updated to all years in the table. Currently I am using the following query to update the current year.
UPDATE FILTERCALENDAR SET YEAR_WINDOW=1 WHERE c_date = NEXT_DAY( TO_DATE('OCT-2013','MON-YYYY'), 'SUNDAY') + (2-1)*7;That's the 2nd Sunday after October 1; the 2nd Sunday of October is the 2nd Sunday after September 30, so you need to subtract 1 more day before calling NEXT_DAY.
I'd do it this way:
WHERE c_date = NEXT_DAY ( TO_DATE ( '01-OCT-2013', 'DD-MON-YYYY') - 8
, 'SUNDAY'
) + (7 * 2) -- Last number is week numberRemember, calling NEXT_DAY like this depends on your NLS_DATE_LANGUAGE.
and for next year Like
UPDATE FILTERCALENDAR SET YEAR_WINDOW=1 WHERE c_date = add_months(NEXT_DAY( TO_DATE('OCT-2013','MON-YYYY'), 'SUNDAY') + (2-1)*7,+12)-1;If you want the 2nd Sunday in October, 2014, then take the previous expression, and just change 2013 to 2014:
WHERE c_date = NEXT_DAY ( TO_DATE ( '01-OCT-2014' -- or any month and year you want
, 'DD-MON-YYYY'
) - 8
, 'SUNDAY'
) + (7 * 2) -- Last number is week number
This is not an excellent way to do it as it does not take care of leap years and it does not scan and update values in the whole table for all years correctly.
Can any one help me to resolve this please.
I hope this answers your question.
If not, post a little sample data (CREATE TABLE and INSERT statements, relevant columns only) for all the tables involved, and the results you want from that data.
In the case of a DML operation (such as UPDATE) the sample data should show what the tables are like before the DML, and the results will be the contents of the changed table(s) after the DML.
Explain, using specific examples, how you get those results from that data.
See the forum FAQ {message:id=9360002} -
How do I get it to show the date & time.
How do I get it to show the date & time at all times. I don't want to have to click on the day & time to get the date. In the OS 10.4 I could at least get it in the "analog" format. Under leopard it just show a little clock that can't be read.
I just want to see the time and date at all times in the upper corner on the screenPlease see my post in your first posting at http://discussions.apple.com/thread.jspa?threadID=1237022&tstart=0
David -
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.... -
Function Module to get first day of the fiscal year on passing a date
Hi Experts!!
Can you please suggest a Function Module to get first day of the fiscal year on passing a date..?
Example: if a fiscal year starts from 30 November 2009 and ends at 28 november 2010.
it should return 30 th nov 2009 (first day of the fiscal year)Moderator message - Welcome to SCN.
I think you'll find that this question has been answered before. Please search the forum before posting.
Also, Please read Please read "The Forum Rules of Engagement" before posting! HOT NEWS!! and How to post code in SCN, and some things NOT to do... and [Asking Good Questions in the Forums to get Good Answers|/people/rob.burbank/blog/2010/05/12/asking-good-questions-in-the-forums-to-get-good-answers] before posting again.
Rob -
I am trying to get "First day of the week" data from CLDR spec24 but cannot find where to look for it in the spec. I need this data to calculate numeric value of "LOCAL day of the week".
This data to implement "c" and "cc" day formats that equals numeric local day of the week.
e.g if "First day of the week" data for a locale is 2 (Monday) , it means numeric value for local day of the week will be 1 if it is Monday that day, 2 if it is Tuesday that day and likewise.Hi
If you want to week to be started with Sunday then use the following formula:
TimestampAdd(SQL_TSI_DAY, 1-DAYOFWEEK(Date'@{var_Date}'), Date'@{var_Date}') if it's retail week(starts from Monday) then the follow below:
TimestampAdd(SQL_TSI_DAY, 1-DAYOFWEEK(Date'@{var_Date}'), Date'@{var_Date}')
I'm assuming var_Date is the presentation variable for prompt...
Edited by: Kishore Guggilla on Jan 3, 2011 4:48 PM
Maybe you are looking for
-
Button Background images created in Indesign do not show up in PDF on some computers.
I have created buttons that let somone swap one image for another in a PDF in Indesign and the copied and pasted the form fields from the exported PDF to the main PDF document. An example can be seen here: http://lustreproducts.com/PDFs/may11/Round
-
March 2015 TechNet Guru Awards! See who's boss in SharePoint 2010! It could be YOU!
The results for March's TechNet Guru competition were posted! http://blogs.technet.com/b/wikininjas/archive/2015/04/17/the-microsoft-technet-guru-awards-march-2015.aspx Below is a summary of the medal winners for December. The last column being a few
-
Need help to upload Excel Chinese data into Oracle
Hello I am very new at internationalization. We are writing an application that reads Chinese data from a Microsoft Excel file and writes it out into Oracle 8i. This is what we have done: 1. Use JDBC-ODBC driver to read the Excel data directly from .
-
Unable to scan doc's using my HP M1536 dnf
I'm facing some new issue using HP laserjet M1536dnf printer & Scanner, in my office number of systems are there, i can able to give print and scan from all systems accept one system i tried so many settings and troubleshoot's but no use its not work
-
Hi EXperts, In my selection screen one radio button group with 3 buttons 1) report 2)download to PC 3)download to APPLICATION SERVER How to handle this situation. Points will be rewarded.