Is it possible to add number of days to date?
I am working on a form where I need to add number of days to a date and come up with a date.
Header 1
Header 2
example date: March 1, 2013
+ 30
= march 31 2013
1. is this possible? Header1/cell 1 is a date field. Header 2/cell 1 is a dropdown field (30, 60, 90,120, custom),.
Header2 cell2 not sure what field to use date or text?
thank you
Never mind I figured it out. Thanks
Similar Messages
-
Need to add number of days to users end date.
Hi,
I have a code where we are adding number of days(30) to current date and then updating user's end date in IDM DB.
Now we have a requirement where we need to add number of days(30) to existing end date of user instead of adding to current date.
*public String incrementDate(int daysToAdd)
// Start date
log.info("NotifyLastDayOfService::incrementDate(): Enter");
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd 00:00:00");
Calendar c = Calendar.getInstance();
c.add(Calendar.DATE, daysToAdd); // number of days to add
String newDate = sdf.format(c.getTime());
log.info("NotifyLastDayOfService::incrementDate(): Exit");
return newDate;
Have any body implemented this scenario?
Please suggest.
Thanks,
Kalpana.Hi Nayan,
Here is the code:
System.out.println("----inside increment date method-----");
HashMap<String, String> hm = new HashMap<String, String>();
HashMap<String,Date> modifyMap=new HashMap<String,Date>();
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd 00:00:00");
tcResultSet usrList = null;
String enddate = null;
hm.put("Users.Key",usrKey );
try {
usrList = this.usrIntf.findUsers(hm);
usrList.goToRow(0);
Date endDate =usrList.getDate("Users.End Date");
System.out.println("-----users end date-----"+endDate);
String userEndDate=sdf.format(endDate);
System.out.println("-----String value of users end date-----"+userEndDate);
Calendar cal=null;
System.out.println("-----Calender date-----"+cal);
cal.setTime(endDate);
System.out.println("-----end date-----"+endDate);
cal.add(Calendar.DATE, Integer.parseInt(daysToAdd)); // number of days to add
Date newEnddate = cal.getTime();
System.out.println("-----new end date-----"+newEnddate);
//usrList.setEndDate(Edate);
modifyMap.put(userEndDate,newEnddate);
usrIntf.updateUser(usrList, modifyMap);
System.out.println("updated user's end date in OIM DB");
//System.out.println("-----updated user's end date in OIM DB-----");
logger.info("NotifyLastDayOfService::incrementDate(): Exit");
System.out.println("-----new date-----");
} catch (tcAPIException e) {
logger.error("Error in finding end date for user" + e);
} catch (tcColumnNotFoundException e) {
logger.error("Error in finding end date for user" + e);
In th log file, I can see that the code is not executing this line:
cal.setTime(endDate);
end date is of type Date and stores users end date from DB. Please help in resolving this issue.
Thakns,
Kalpana. -
Function module which convert number to days to date
Hi,
Any one knows any function module which convert total number of days into date.
thnaks,
shilpa kHi,
FIMA_DAYS_AND_MONTHS_AND_YEARS
FI_PSO_DAYS_MONTHS_YEARS_GET
RSSM_CONVERT_DAYSEC2TIMESTAMP
RSSM_CONVERT_TIMESTAMP2DAYSEC
Function Modules related to Date and Time Calculations
DATE_COMPUTE_DAY : Returns weekday for a date
DATE_GET_WEEK : Returns week for a date
DAY_ATTRIBUTES_GET : Returns attributes for a range of dates specified
MONTHS_BETWEEN_TWO_DATES : To get the number of months between the two dates.
END_OF_MONTH_DETERMINE_2 : Determines the End of a Month.
HR_HK_DIFF_BT_2_DATES : Find the difference between two dates in years, months and days.
FIMA_DAYS_AND_MONTHS_AND_YEARS : Find the difference between two dates in years, months and days.
MONTH_NAMES_GET : Get the names of the month
WEEK_GET_FIRST_DAY : Get the first day of the week
HRGPBS_HESA_DATE_FORMAT : Format the date in dd/mm/yyyy format
SD_CALC_DURATION_FROM_DATETIME : Find the difference between two date/time and report the difference in hours
L_MC_TIME_DIFFERENCE : Find the time difference between two date/time
HR_99S_INTERVAL_BETWEEN_DATES : Difference between two dates in days, weeks, months
LAST_DAY_OF_MONTHS : Returns the last day of the month
Regards -
Adding Number of days to date in XI
Hi
I have a scenario where in i have add the number days to date.
ex: if the date is 02092009 and if the days is 30. then the result of adding days to the date should be 02102009.
Do we have any readily available UDFs in XI if not it would be appreciated if i can get some procedure to implement this.Hi ,
you can use this code in user defined function
Calendar cal = Calendar.getInstance();
/* here u can parse the individual values for year month and day, other calendar function are also available .*/
cal.set(1999,11,28);
/* here instead of value 30 u can pass the specific node integer value to add the no of days.*/
cal.add(Calendar.DATE, 30);
return cal.getTime().toString();
Regards,
Syed -
Hello -
I've been tearing my hair out over this problem i'm trying to solve, probably just been staring at it too long which is making it worse -
I have a series of open support tickets which are supposed to be updated on a daily basis, the problem is that they aren't always being updated daily. So, the business wants to know the number of days from when a ticket was last updated and today's
date. I have this basic calculation and it's working fine, however now the business wants to exclude weekends from the calculation. The other problem is that some reps DO go in on weekends and update their tickets, so sometimes there will be updates
made on weekend dates.
To give an example -
Today's date is 2014-02-10 (Monday). A ticket was last updated last Thursday, 2014-01-30. The difference between the two dates is 11, so it's been 11 days since the ticket was last updated. Now, if I exclude Saturdays and Sundays, then
it's actually been 7 days since the ticket was last updated. I'm not sure how to do this in T-SQL.
Now, to further complicate the problem, sometimes a ticket IS updated on a Saturday or Sunday. So, if a ticket was updated on 2014-02-02 (Sunday), then it should be counted. Again i'm not sure how to do this.
What gets me is that this is probably fairly simple and i've just been staring at it too long. In the meantime, can someone offer some guidance?
Thanks!!I've adapted this from a function on my blog. you will need to add set the YourTicketTable to where ever your tickets are stored.
CREATE
FUNCTION [dbo].[CalcWorkDaysBetween](@StartDate
As DateTime,@EndDate
AS DateTime)
RETURNS
INT AS
BEGIN
SET @EndDate
=DATEADD(DAY,1,@EndDate)
DECLARE @Count
AS Int= 0
DECLARE @Date
As Date=@StartDate
WHILE @Date
< @EndDate
BEGIN
IF (DATEPART(WEEKDAY,@Date)IN(1,7)
OR (SELECT
Count(*)
FROM YourTicketTable WHERE TicketDate=@Date)=1)
BEGIN
SELECT @Count = @Count
+ 1
END
SELECT @Date=DATEADD(Day,
1,@Date)
END
RETURN
DATEDIFF(DAY,@StartDate,@EndDate)- @Count
END
Regards, -
Number of Days in Date and 7pm anomaly
I have found a bizarre behavior with find the number of days for a date( since Jan. 1, 1970 ). I needed a way to calculate the number of days between two dates. I did this by using the getTime() method on the dates, then dividing them by one day in milliseconds (86400000). I then cast them to an int to trucate the decimals. This gave the number of days since Jan 1, 1970. I then subtracted the two 'number of days' values to get the number of days between the 2 dates.
This was working fine until we ran into a problem of it returning one day to many in a seemingly random pattern. The problem ended up being that after 7pm dividing a date in milliseconds form by a day in milliseconds would return one more day, than if the date was before 7pm.
example:
November 1, 2004 00:00:00 = 1099288800000ms = 12723.25 days = 12723 truncated
November 1, 2004 19:00:00 = 1099357200000ms = 12724.04 days = 12724 truncated
Why is this? Why is 12am Nov 1 not an even number of days? Supposedly the Date class starts from Jan 1, 1970 00:00:00. If everyday is 86400000ms then this behavior shouldn't happen. Does anyone know why this anomaly happens?You need to take into account time zone. If you are at GMT+0 there is no problem (unless you switch to daylight sayings :)
For example you can take a System.currentTimeMillis() and send it anywhere in the world and it would display locally with the right time.
I guess you are at -5 hours from GMT. (Eastern time of the US/Canada timezone). The Date object makes corrections for timezone.
So in England, the time would have been 0 at Jan 1 1970, 00:00:00
Another thing you may need to worry about is daylight savings changes, which again are handled by the Date object.
The simplest thing to do is use the Date object. If this is a performance issue you can do some tricks to reduce the impact. e.g. store the default Timezone and Local locale as constants and use these to build the Date object. -
Hi, all
somebody know if i can add days to a date with a dynamic action??
Thank for your helpHi Francisco,
You can use a external subroutine to do so.
In the dynamic action:
for that infotype you can specify an entry with Step type F and Variable function part with the routine name(The new calculated date is returned in the RP50D-DATE1 field)
EXAMPLE:
STEP1 :In dynamic action create these 2 entries
0000| | | 06 | 457 | F | GET_DATE(ZHPADYN).
0000| | | 06 | 456 | W | P0041-DAT01=RP50D-DATE1
STEP2: Then create Subroutine pool in SE38 ( Program type S)
PROGRAM ZHPADYN.
TABLES : RP50D,
P0000.
*& Form GET_DATE
FORM GET_DATE .
RP50D-DATE1 = P0000-BEGDA - 1.
ENDFORM. "GET_DATE
Hope this helps.
Thanks,
Puneet -
How to add number of years to date
Hello,
How can I add a number of years (age) to a date (not the current date, the birth date, chosen from a DatePicker).
Thank you,
Ioana.Wow, that was fast :)
Sorry for the double post, wasn't sure the first one was published.
Thanks a lot, I've managed to add the the age correctly.
Ioana. -
Adding an "x" number of Days to Date Object
Hi guys,
What I would like to is lets say you have a date object, looking for method/way of adding or subtracting X amount of days from that object.
This is because I have a list of dates that I would like to follow up on eachother like :
1/7/06-5/7/06(Date EndDate)
(Date EndDate + 1) i.e 2/7/06 - 31/7/06
Thanks in advanceFor anyone that has the same problem this is how I got it working.
Thanks for the help in the post.
static Date addDaysToDate(Date startMonth, int days)
Calendar c = Calendar.getInstance();
c.setTime(startMonth);
c.add(Calendar.DATE, days);
startMonth = c.getTime();
return startMonth;
} -
Number of days (current date-goods receipt date)
Hi All,
I have a requirement like this :
need to display no of days in Query which is CKF=current date-GR date. GR date is coming from r/3.We do not have current date field. and moreover no of days is in the selection screen.So we should have no of days calculated already in the cube.am i rght? calculation shold be done before data comes into the cube i.e in transfer rules or update rules...thats what i thought.Am i rght? can anybody come up with some code to calculte no of days in transfer rules or update rules?
pl correct me if i am wrong.
regards
Message was edited by: cmdWhen your write code in transfer rules it will be global.
if u write code in update rules it will local to on data target.
Transfer rules----
InfoSource
Update reules----
data target.
here infosource is re-usable to other datatargets, so it will effect to all.
but update rules is only one data target.
i think u clar about this.
pls assgain poinst, if u satify.
by
ANR -
Substracting number of days from date
Hi all, I need to create a user exit to get a date value based on another variable. Basically, 100 days minus the first variable.
var2 = var1 - 100
How can I write this?
Thanks.Ok, I figured it out. I had to declare variables of type d and then assign it.
IF i_step = 2.
data:zday type d,
zday1 type d.
*****Loops for Variable.*****************************************
LOOP AT I_T_var_range
INTO loc_var_range WHERE
VNAM = 'ZENDT' or
VNAM = 'ZENDATE'.
zday = loc_var_range-low.
zday1 = zday - 275.
* l_S_range-low = loc_var_range-low - 275.
l_S_range-low = zday1.
l_s_range-sign = 'I'.
l_s_range-opt = 'EQ'.
APPEND l_s_range TO E_T_range.
ENDLOOP.
EXIT.
ENDIF. -
Is it possible to add the YEAR to the date shown in the Lockscreen?
TIA.
Hi,
We cannot display the year information on Windows 8.1 Lock Screen.
The behavior is by design.
Thanks for your understanding.
Regards,
Kelvin Xu
TechNet Community Support -
Hi,
I want to add number of days in a date string using jsp.
<%--
Document : try5
Created on : May 20, 2008, 6:00:20 PM
Author : thamaraiselvan
--%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>JSP Page</title>
</head>
<body>
<%
String datetxt="2008-05-20";
%>
</body>
</html>How to add 30,90,180,365 days in that String datetxt value.
Thanks Alot....Hi,
How to format a string value into a Date.
I typed the following code .but its gives a exception.
<%--
Document : try5
Created on : May 20, 2008, 6:00:20 PM
Author : thamaraiselvan
--%>
<%@page contentType="text/html" pageEncoding="UTF-8" import="java.sql.*,java.util.Date,java.util.Calendar,java.text.SimpleDateFormat" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>JSP Page</title>
</head>
<body>
<%
try
String datetxt="2008-05-20";
int e=30;
// calendar.set(Calendar.DAY,calendar.get(Calendar.DAY)+30);
// Calendar cal = Calendar.getInstance();
//Date today = cal.getTime();
SimpleDateFormat fmt =new SimpleDateFormat("yyyy-MM-dd");
String thamu = fmt.format(datetxt);
out.println(thamu);
catch(Exception e)
out.println(e);
%>
</body>
</html>Exception Like This :
java.lang.IllegalArgumentException: Cannot format given Object as a Date .
After Formatting to date i want to add 180 days from '2008-05-20' .
Please Help me...
Thanks Alot.... -
Number of Days with difference in 2 columns
Dear all,
Is this possible to display Number of Days with difference in 2 columns.
Regards,Or use simply the ABS() function
select abs( date1 - date2 ) from dual ;Francois -
Convert number of dayes per year to data
Please i need help in Convert number of dayes to date
I have ID's like id
FT*09025*0000000001 date=20090125
FT*01171*0000000002 date=20100620
so should convert first five number after FT to date
example *09025*
09 map to 2009
025 number of dayes per year map to 25 jan
example *01171*
01 map to 2010
171 number of dayes per year map to 20 jun
(jan+feb+mar+apr+may)=(31+28+31+30+31)=151
171-151=20 for the next month
Please need help so will added filter to informatica map with date
Edited by: user8929623 on Jul 4, 2010 7:04 PMWell, I do not follow why when 09 maps into 2009, 01 maps into 2010, not into 2001. Assuming it should be 2001, use YYDDD format:
SQL> with t as (
2 select 'FT*09025*0000000001' id from dual union all
3 select 'FT*01171*0000000002' from dual
4 )
5 select to_date(substr(id,4,5),'yyddd') dt
6 from t
7 /
DT
20090125
20010620
SQL> SY.
Maybe you are looking for
-
Problem in saving long text data from custom
Hi Expert, I am working on a screen exit in QM01. I have created a editor box(like the description box under Description tab in QM01) using class cl_gui_custom_container and cl_gui_textedit. I am able to create and display the text I type in the box
-
Cannot find Compass in Home Applications folder
i have swipped my torch 9860 phone as i wanted to remove all apps i've installed in my phone. but after i did that i couldn't find Compass in Applications folder. I tried to search it using global search but it shows nothing. Due to this i'm not able
-
How does the newest Iphone work with Ford Sync?
How does the new Iphone work with Ford Sync? I was thinking of purchasing the 4s but may go elsewhere if there is a better phone for the equipment in my vehicle.
-
After 6 years of trouble-free service, my iMac (17" G4, 1.25 Ghz) won't boot past the gray screen with the apple and the spinning ball. It was running on 10.5.8. I've tried everything I could find in the Apple troubleshooting articles, including rese
-
Reducing size of pdf in OSX Lion
Ladies and Gents, Can you please let me know how I can reduce the size of pdf docs in OSX Lion. I use to be able to save as pdf, open it again and then "save as" with reduce option. In lion it only shows "Save version" instead of "save as". Thanks in