Adding hours/day to a date
Hello,
I have field of length 20 which contains date in the format mm/dd/yyyy hh:mm:ss.
I want to add 5 hrs, 8 hrs, 2 days to this date value depending upon some condition.
Can anyone please suggest how to do this or any FM which does this.
Thanks in advance
Hi..
DATA : FA(20) TYPE c,
FB(10) TYPE c,
FC TYPE d,
FD(8) TYPE c,
FE TYPE t.
data : f_m(10) type c,
f_d(10) type c,
f_y(10) type c,
f_h(10) type c,
f_mi(10) type c,
f_s(10) type c,
f_aa(10) type c,
f_bb(10) type c.
FA = '07/01/2007 08:09:10'.
SPLIT fa AT space INTO f_aa f_bb.
SPLIT f_aa AT '/' INTO f_m f_d f_y.
SPLIT f_bb AT ':' INTO f_h f_mi f_s.
add your logic...
i want to help you.
regards..
Similar Messages
-
Adding 1 day to a date in BPEL
Hi,
Im trying to add 1 day to a date in a BPEL proces. I saw that there was a xp20:add-dayTimeDuration-to-dateTime so I tried using this in several ways. I didnt expect the input variable to be a string. I tried converting my date to a string and adding 1 day like this:
xp20:add-dayTimeDuration-to-dateTime(xp20:format-dateTime(string(bpws:getVariableData('inputVariable','payload','/ns1:GereedMeldenRoosterRequest/StartDatum')), 'YYYY-MM-DD'), 'P1D')
But the variables which I try to fill stays empty. The element which I try to fill is of type dateTime. Is this maybe the error that add-dayTimeDuration-to-dateTime returns a string and it cannot cast it to dateTime?
Can anyone tell me how to solve this properly?
Thanks in advance!Hi,
I refactored my expression to look like this:
xp20:format-dateTime(xp20:add-dayTimeDuration-to-dateTime(bpws:getVariableData('inputVariable','payload','/ns1:GereedMeldenRoosterRequest/StartDatum'), 'P1D'), '[Y]-[M]-[D]')
But the I receive an error: XMLElement cannot be cast to java.lang.String
Then I tried:
xp20:format-dateTime(string(xp20:add-dayTimeDuration-to-dateTime(bpws:getVariableData('inputVariable','payload','/ns1:GereedMeldenRoosterRequest/StartDatum')), 'P1D'), '[Y]-[M]-[D]')
Because xp20:add-dayTimeDuration-to-dateTime needs a String as input and I dont know how getVariableData returned it but with this I get the error:Parse Error in string function
Any ideas? -
Adding 30 days to a date in a dynamic LC form
Hello-
I'm working on a dymnamica form that is merged with XML data. In the XML, I get a FirstQuoteDate and bind it to the corresponding field in the form. I then have to calculate the ValidDate by adding 30 days to the FirstQuoteDate and display that date int he Valid Date field.
I've tried several scripts with no luck. Below is the latest script I tried. I also tried the script in several different events. I believe it is the calculate event for the ValidDate field right now. Does anyone know what I am doing wrong?
var QuoteDt = Date2Num(PROPOSAL.Page2Summary.FirstQuoteDate.rawValue, "MM/DD/YY")
var FutureDt = QuoteDt+30
var ValidDt = Num2Date(FutureDt, "MM/DD/YY")
PROPOSAL.Page2Summary.ValidDate.rawValue = ValidDtWhat event should I be putting this script in? Am I thinking I can't put it in the Change event because the date isn't being entered through the form so the field never actually changes? Do I have to use a different event? The FirstQuoteDate and ValidDates are actually floating text fields in my form. I did find that example out there from a different discussion and have tried this script in the initialize event of the First QuoteDate field and it didn't work for me.
ValidDate.rawValue = Num2Date(Date2Num(xfa.event.newText, "M/D/YYYY")+30,"MM/DD/YYYY"); -
Adding Business Days to a Date
Hi everyone,
I'm trying to add a certain number of working days to a date,what I am hoping to get is a date excluding the weekends
For example:
If i was to add 12 working days to 01/05/2009 i should get 19/05/2009
Thank You
MTMistook 01/05/2009 as Jan 5th and was wondering why your statements contradicted. I see you mean May 1st.
Try a formula such as this:
numbervar i := 1;
datevar c := date(#05/01/2009#);
numbervar z := 12;
datetimevar k := date(0,0,0);
while i <= z do
k := dateadd('d',i,c);
(if dayofweek(k) in [1, 7] then
(z := z + 1;)
k := date(0,0,0);
i := i +1;
dateadd('d',z,c);
where 'C' is the starting date and 'Z' is the number of working days. -
Adding Business Days to a Date to create New Date
I am looking to add a formula to auto calculate a new date, but only want to count business Days.
Currently I am using formula to calculate how many days need to be added:
//ODD Priority Business Days
If left ({DEFECT.PRIORITY}, 1)= "1" then 10
else
If left ({DEFECT.PRIORITY}, 1)= "2" then 20
else
If left ({DEFECT.PRIORITY}, 1)= "3" then 50
else
If left ({DEFECT.PRIORITY}, 1)= "0" then 10
Now I need to create a formula to add these numbers to the date field, for conversation purposes, I need to add these business days to my "start date" to equil my "ODD date".
Example, if my "start date" is 1/1/2009 and it is a Priority 2, then I need to add 20 business days to that, so the "ODD date" would be: 1/29/2009.
Please help.Thank you Garrett Fitzgerald! Please see the modified formula which I meant
{Startdate}
+ {@BusinessDays}
- DateDiff("ww", {Startdate}, {Startdate} + {@BusinessDays}, crSaturday)
- DateDiff("ww", {Startdate}, {Startdate} + {@BusinessDays}, crSunday)
Regards,
Raghavendra -
Req for FM for adding some days to sy-date
Hi experts,
my requirement is I have some 'X' number of days to finish my work.
And I need to add these number of working days (let me say 10 days )to the system date.
sy-date + 10 gives me the weekend days also.
so I need to skip the weekend days.
Do u guys have any FM or any logic to perform my task.
Thanks in advance,
Sudha........Please do a search before posting.
FM BKK_ADD_WORKINGDAY (despite the name it also does subtraction). -
Adding 1 day to a date of format YYYYMMDD format and it is char.
HI,
I have a column checktodate which is declared as char(8) and it is of format YYYYMMDD.
some of the values in the checktodate column are null and blank also.
I have to give a condition as
checktodate+1>= sysdate.
I am giving as
TO_CHAR(to_date(nvl(CHECKTODATE,0),'yyyymmdd')+1,'yyyymmdd') >= TO_CHAR(SYSDATE ,'YYYYMMDD')
I am getting the error as
ORA-01840: input value not long enough for date format
01840. 00000 - "input value not long enough for date format"
*Cause:
*Action:
kindly suggest.
Thank you.
Regards
Chaitanya.I gave the below conditions like this
select xyz,asdf,
(CASE WHEN TO_DATE(checktodate,'YYYYMMDD')+1 >= SYSDATE
THEN CHECKTODATE
ELSE TO_CHAR(SYSDATE ,'YYYYMMDD')
END) startdate
FROM dummy
where checktodate IS NOT NULL
AND INSTR(CHECKTODATE,' ') = 0
I am getting the following error
ORA-01839: date not valid for month specified
01839. 00000 - "date not valid for month specified"
*Cause:
*Action: -
Adding one day to a oracle.jbo.domain.Date and truncating the time part
JDev 11.1.1.4.0
Hello
I need to add a day to oracle.jbo.domain.Date and get back a oracle.jbo.domain.Date without the time part.
So far I've got
Date valueDate = (Date)rowCpt.getAttribute("ValueDate");
Calendar cal = Calendar.getInstance();
cal.setTime(new java.util.Date(valueDate.timestampValue().getTime()));
cal.add(Calendar.DATE, 1);
Date newDate = new oracle.jbo.domain.Date(new Timestamp(cal.getTime().getTime()));This adds 1 day to the date but keeps the time part of the date.
How do I get rid of the time part of the date ?
Thanks
PaulThe Calendar class allows you to set or clear each field.
Date valueDate = (Date)rowCpt.getAttribute("ValueDate");
Calendar cal = Calendar.getInstance();
cal.setTime(new java.util.Date(valueDate.timestampValue().getTime()));
cal.add(Calendar.DATE, 1);
cal.clear(Calendar.HOUR);
cal.clear(Calendar.MINUTE);
cal.clear(Calendar.SECOND);
cal.clear(Calendar.MILLISECOND);
Date newDate = new oracle.jbo.domain.Date(cal.getTimeInMillis());should work.
Timo -
XQuery function : Adding day to current date
I have a requirement to add 1 day to the current date during the Xquery transformation.
Does anyone know if there is any xquery function that does that?
From this link,
http://download.oracle.com/docs/cd/E13214_01/wli/docs92/xref/xqdtopref.html#wp1162860
it seems like there is a function, op: add-yearMonthDuration-to-dateTime, that serve this purpose, but I don't find it in OSB console IDE nor OEPE.You can use the below expression for adding 1 day (24 hrs) to a given current date:
fn:current-dateTime() + xdt:dayTimeDuration("PT24H")
Thanks,
Patrick -
Hi, i've been trying to add days to a date with no luck.
I have two dates.
Date date1= new Date();
Date date2;
I want date2 to equal x amount of days from date1.
eg. date1 = 6/10/2004
I want date2 to be 4 days from date1 so date2 would be 10/10/2004. i know this is very easy to do with the Calendar class but in my program it needs to be a Date because i parse Strings (dd/mm/yyyy) to Dates. It is not possible to parse Strings to Calendar date's right?
So if anyone can help me add days to a Date object, it would be great!
Thanks>
testParse.java:33: 'void' type not allowed here
System.out.println (testDate2.setTime(newTime));You are trying to print out the results of the void
method, i.e. a void, not the object.
d-unknown, if you look closely at the error message provided and the line it's complaining about, and use a little process of elimination, I think you'll find that there are only so many possibilities as to what possibly could be wrong.
These compiler errors are not cryptic curses thrown up to stop people from getting work done, the counterspells to which are only known to those who have been through the rite of passage and had a coffee cup branded on their butts. The error messages are your friends. They tell you pretty precisely what went wrong and where if you take the time and effort to read an understand them.
"'void' type not allowed here" -- Where have you ever seen the word void when programming Java? As the return type of a method, right? So, "'void' type" is probaby talking about the return type of some method.
"not allowed here" -- well, it looks like you're doing something with a void where you can't have a void.
There are only two method calls on that line--println and setTime. Both return void, so either one could be the problem. Either one might be being used where it's not allowed.
But wait, what could possibly be wrong with where you're using println? It's just like every other println you've ever used.
What about setTime? Well, println has several signatures. One takes object, and there's one for int, float, etc. So what you pass to println has to be one of those types. Is the return type of setTime an Object or int or long or anything? No, it's void. It's nothing. It has no value. println needs a value, but you're passing something that has no value. It would be like saying x=date2.setTime(...) It makes no sense, because a method with a void return type doesn't return any value.
See, that wasn't so hard, was it? Yeah, it was wordy, but really if you start with "what could be void in this line and how could it be causing a problem," the thought process only has a few steps to get to the answer. -
Help on calendar.add() adding -60 days
hi all
i am having problem with the add() in Calendar class. i try to get a date that is 60 days prior to the current date, and here is what i coded:
Calendar calendar = new GregorianCalendar();
System.out.println("current day : "+calendar.toString());
calendar.add(Calendar.DAY_OF_MONTH, -60);
System.out.println("after adding (-60), the day is "+calendar.toString()); and here is the output of the print:
--- getEffectiveDate ---
current day : java.util.GregorianCalendar[time=1088608525321,areFieldsSet=true,a
reAllFieldsSet=true,lenient=true,zone=sun.util.calendar.ZoneInfo[id="America/New
_York",offset=-18000000,dstSavings=3600000,useDaylight=true,transitions=235,last
Rule=java.util.SimpleTimeZone[id=America/New_York,offset=-18000000,dstSavings=36
00000,useDaylight=true,startYear=0,startMode=3,startMonth=3,startDay=1,startDayO
fWeek=1,startTime=7200000,startTimeMode=0,endMode=2,endMonth=9,endDay=-1,endDayO
fWeek=1,endTime=7200000,endTimeMode=0]],firstDayOfWeek=1,minimalDaysInFirstWeek=
1,ERA=1,YEAR=2004,MONTH=5,WEEK_OF_YEAR=27,WEEK_OF_MONTH=5,DAY_OF_MONTH=30,DAY_OF
_YEAR=182,DAY_OF_WEEK=4,DAY_OF_WEEK_IN_MONTH=5,AM_PM=0,HOUR=11,HOUR_OF_DAY=11,MI
NUTE=15,SECOND=25,MILLISECOND=321,ZONE_OFFSET=-18000000,DST_OFFSET=3600000]
after adding (-60), the day is java.util.GregorianCalendar[time=1083424525321,ar
eFieldsSet=true,areAllFieldsSet=true,lenient=true,zone=sun.util.calendar.ZoneInf
o[id="America/New_York",offset=-18000000,dstSavings=3600000,useDaylight=true,tra
nsitions=235,lastRule=java.util.SimpleTimeZone[id=America/New_York,offset=-18000
000,dstSavings=3600000,useDaylight=true,startYear=0,startMode=3,startMonth=3,sta
rtDay=1,startDayOfWeek=1,startTime=7200000,startTimeMode=0,endMode=2,endMonth=9,
endDay=-1,endDayOfWeek=1,endTime=7200000,endTimeMode=0]],firstDayOfWeek=1,minima
lDaysInFirstWeek=1,ERA=1,YEAR=2004,MONTH=4,WEEK_OF_YEAR=18,WEEK_OF_MONTH=1,DAY_O
F_MONTH=1,DAY_OF_YEAR=122,DAY_OF_WEEK=7,DAY_OF_WEEK_IN_MONTH=1,AM_PM=0,HOUR=11,H
OUR_OF_DAY=11,MINUTE=15,SECOND=25,MILLISECOND=321,ZONE_OFFSET=-18000000,DST_OFFS
ET=3600000]it looks like it only subtracted 30 days from current date. i wonder what happen to the 60 days. does anyone have any idea why? thanks for ur help.DateFormat df = DateFormat.getDateInstance(DateFormat.SHORT);
Calendar calendar = Calendar.getInstance();
System.out.println("current day : " + df.format(calendar.getTime())); // 6/30/04
calendar.add(Calendar.DAY_OF_MONTH, -60);
System.out.println("after adding (-60), the day is " + df.format(calendar.getTime())); // 5/1/04What's the problem? -
How To Add Days into a Date from java.util.Date class
I have a problem when i wants to add 2 or days into a
date object geting by java.util.Date class. so please help me resolve this issue?
for e.g i have a date object having 30/06/2001,
by adding 2 days i want 02/07/2001 date object ?
Code
public class test2
public static void main(String args[])
java.util.Date postDate = new java.util.Date();
myNewDate = postDate /* ?*/;
Here i want to add 2 date into postDateUse Calendar...
Calendar cal = Calendar.getInstance();
cal.setTime(new Date());
cal.add(Calendar.DAY, 2); // I'm not sure about that "DAY" -
What is the best way to add a day to a Date object?
I have come across numerous examples on adding a day to the CURRENT date, using the Calendar object. However, what I need to do is to add a day to a Date variable.
Can someone tell me how to do that? I tried to set the value of my Date variable into the Calendar object, but, it appears that for the current JAVA version, they have deprecated the getYear(), getMonth() and getDay() methods for the Date class.
Really appreciate your suggestions.
Thank you in advance,
SiowLingI haven't seen the OP express a concern over how to create/obtain the Date object (he could be using "new Date()" given the emphasis on "CURRENT"). Milliseconds is fine too if that's what you have (for example from a java.sql.Date).
So the way to add a day to a Date object (the OPs original question) is to:
- set the Date on a Calendar using setTime
- add 1 to the DATE field of the calendar
- get the Date from the Calendar using getTime
Obviously you're right if the OP doesn't have Date object to start with, but just the "numbers" for year, month, day. -
Extract data on report between last 30 days from current date.
Hi Experts,
Ealrier i had provided user promt to select the date range, now i need to schedule the report for this i have to set the date between last 30 days from current date.
How can i add this in formaula on record selection.
before:
{pm_process.pm_creation_date} in {@Start Date to UTC} to {@End Date to UTC}
I tried:
{pm_process.pm_creation_date} in CurrentDate() - 30 to CurrentDate()
But this is diplaying me only data of 30th date from current date.
Please advice.Hi Brian,
Thank you!
1. I have not created any function for {pm_process.pm_creation_date} in [CurrentDate() - 30 to CurrentDate()] i am just adding this on Record Selection and its not helping.
2. {pm_process.pm_creation_date} in Last30Days; this is throwing below error.
please advice what to be done? -
Adobe LiveCycle Designer 8 - Add days to Current Date in another text field
Hi-
I am working on an expense report. I have six fields, CurrentDate, and countDate1 through countDate5. The CurrentDate is a Time/Date field which the user can select whatever date is needed with the drop down calendar. The other five countDate fields are "text" fields which will represent Monday through Friday. I would like to add zero days to whatever the user selects as the CurrentDate and make that appear in countDate1 which represents Monday(the CurrentDate the user selects will always be a Monday), add one day to whatever the user selects as the CurrentDate and make that appear in countDate2 which represents Tuesday...and so on. I realize this is probably basic for someone familiar with FormCalc but I'm very new at this.
This got me very close but I want the user to select the date and not have the CurrentDate already filled in.
CurrentDate - DateTime field, FormCalc calculation script:
num2date(Date())
Date1 - Text field, FormCalc calculation script:
Num2Date( Date2Num(CurrentDate.formattedValue))
Date2 - Text field, FormCalc calculation script:
Num2Date( Date2Num(CurrentDate.formattedValue) + 1 )
Thanks!
BrianHere is an exmaple of adding days the script is used in the "exit" event for the date select field that has display format of "MM/DD/YYYY". Adding days requires add x number of days to the days since the epoch date for the current date, adding months or years one needs to manipulate the string parts of the date.
----- form1.#subform[0].InputDateField::exit: - (FormCalc, client) ---------------------------------
// fomatted string for selected date
var sFmtDateValue = $.formattedValue
var sMsg = Concat("Entered date formatted: ", sFmtDateValue) // build message string
sMsg = Concat(sMsg, "\u000a" ) // add new line to message
// convert date string to days since epoch date - format is important
var fDaysPast = Date2Num(sFmtDateValue, "MM/DD/YYYY")
// add 7 days to days past epoch date
var f7DaysPlus = fDaysPast + 7 // add 7 days
var s7DaysPlus = Num2Date(f7DaysPlus, "MMM DD, YYYY") // format string for 7 days plus
sMsg = Concat(sMsg, "\u000a", "Plus 7 Days: ", s7DaysPlus) // build message string
// add 14 days to days past epoch date
var f14DaysPlus = fDaysPast + 14 // add 7 days
var s14DaysPlus = Num2Date(f14DaysPlus, "MMMM DD, YYYY") // format string for 7 days plus
sMsg = Concat(sMsg, "\u000a", "Plus 14 Days: ", s14DaysPlus) // build message string
// display results
// work on months
// get parts of date past epoch date
var sFullYear = Num2Date(fDaysPast, "YYYY") // get 4 digit year form days past epoch date
var sMonth = Num2Date(fDaysPast, "MM") // get month form days past epoch date as number
var sDate = Num2Date(fDaysPast, "DD") // get date form days past epoch date as a number
var s2Month = Sum(sMonth, 2) // add 2 months
var s2FullYear = sFullYear
// if more than 12 months in new date adjust year on number of months
if (s2Month > "12") then
s2FullYear = Sum(s2FullYear, + 1) // increment year
s2Month = Sum(s2Month, - 12) // adjsut months
endif
var s2MonthsAdded = Concat(s2Month, "/", sDate, "/", s2FullYear) // date string
sMsg = Concat(sMsg, "\u000a", "Added 2 months: ", s2MonthsAdded) // display stringxfa.host.messageBox(sMsg, "Sample Adding Days" ,3, 0);
var s5Month = Sum(sMonth, 5) // add 5 months
var s5FullYear = sFullYear
// if more than 12 months in new date adjust year on number of months
if (s5Month > "12") then
s5FullYear = Sum(s5FullYear, + 1) // increment year
s5Month = Sum(s5Month, - 12) // adjsut months
endif
var s5MonthsAdded = Concat(s5Month, "/", sDate, "/", s5FullYear) //build Date string
sMsg = Concat(sMsg, "\u000a", "Added 5 months: ", s5MonthsAdded) // display stringxfa.host.messageBox(sMsg, "Sample Adding Days" ,3, 0);
// display results
xfa.host.messageBox(sMsg, "Sample Adding Days and Months" ,3, 0);
Maybe you are looking for
-
Dont know what to say......
First time I use this method in my program int j starts with the value 0 but second time I use the method in the same program int j keeps on starting getting 1 and I just dont get why?? void findPosition2(Component k�[],int x,int y,Component c)
-
Hi All, I have a Hierarchy on infoobject 0MATERIAL. When we execute the report, the results rows are only shown for some nodes but not for others of the same level. The setting "Root/Totals Item Appears Above" is set. Also, the characteristic 0MATERI
-
Open CL for Adobe Premiere Pro CS 5.5
How can i use AMD Radeon R9 M290X with 4 GB inside an iMac 5K with Premiere Pro CS 5.5 to use the GPU supporting of Mercury Playback Engine. Is there a patch or update for CS 5.5 available which support this. I want to stay with CS 5.5 now, i am happ
-
Can't play a track that I downloaded from iTunes.
I just downloaded an audiobook from iTunes. For some reason I'm not able to play the third track. It won't sync to my iPod either. The error that I get when I try to add it to my iPod is: "Track Name" was not copied to the iPod "Jack's iPod" because
-
How to open JSP session from a java application or an applet?
Hi, My problem is a bit challenging (at least for me) and its not about JSP but it is about a web application.. I couldnt find a better place to post this question I am sorry if this is not the right place to post it.. I need to enable users log into