Todays date plus a set number of days
I know I'm just having a brain fart here, this has got to be
easier than I'm making it.
Essentially, I have a variable bit of text that I need to
display todays date + 10 days.
Getting todays date and formatting it are simple I know:
var today_date:Date = new Date();
// place date into US date format
var date_str:String =
(today_date.getMonth()+1)+"/"+(today_date.getDate()+"/"+today_date.getFullYear());
// display current date
trace(date_str);
The problem lies in making todays date plus 10 days..... any
ideas anyone?
~Chuck Moulton
Do your date additions with the Date object then extract the
data to do the formatting afterwards...
var today:Date = new Date();
trace(today); //today
var addAWeek:Number =7; //days
today.setDate(today.getDate()+addAWeek)
trace(today); //its not today anymore its a week from today
//extract the portions and format now
Similar Messages
-
I want to repeat an event on a set number of days.
I work shift work and my schedule repeats every 28 days. For example, I work day shift today and in 28 days I will work day shift. I want to input my work schedule into iCal, but it doesn't let me create a repeatable event for a certain number of days. I would manually have to enter my work schedule every month. Can we get this changed. I know several of my co-workers have iPhones and would like to have this feature. We would like to deal with just one calander, versus several. Google calender has this feature, and that is what we currently use, but we want to use the iCal app. Thanks for the help and input.
I found a work around. iCal in iCloud will let you customize your iCal entries; so I inputed my custom work schedule and then it just updates your iPhone.
-
Adding Date/Time Field + X Number of Days - Basic Calculation Question
I am assuming this is a basic calculation question. New to Adobe LiveCycle Forms.
I have a simple form containing a table. The table appears as such:
Text
Formatted as Date/Time Fields
Header 3
Monday
user wil choose the beginning date (Date/Time) this is DateTimeField1
Tuesday
this should calculate DateTimeField1 + 1
Wednesday
this should calculate DateTimeField1 + 2
Thursday
this should calculate DateTimeField1 + 3
Friday
this should calculate DateTimeField1 + 4
Saturday
this should calculate DateTimeField1 + 5
Sunday
this should calculate DateTimeField1 + 6
Calculations are performed after the date is chosen for Monday. My mind tells me the simple calculation of DateTimeField1 + 1 is not going to work (and in fact doesn't!) as it needs to change Monday to a number first. I saw on another thread the following:
Num2Date(Date2Num(Date(DateTimeField1), "DD.MM.YYYY")+7, "DD.MM.YYYY")
Thought this was going to get me close. No cigars though!
Any quick help is greatly appreciated. And since I am new to this, details about what needs to be changed would be great too!
ThanksHere an addition for you date field.
This FormCalc script in the exit:Event will check it the selected date is on a monday.
If not it will go the days back until the last monday.
var Selection = Date2Num($.formattedValue, DateFmt(2))
var WeekDay = Num2Date(Selection, "E")
var NewDate
if (WeekDay eq 1) then
NewDate = Selection - 6
elseif (WeekDay eq 3) then
NewDate = Selection - 1
elseif (WeekDay eq 4) then
NewDate = Selection - 2
elseif (WeekDay eq 5) then
NewDate = Selection - 3
elseif (WeekDay eq 6) then
NewDate = Selection - 4
elseif (WeekDay eq 7) then
NewDate = Selection - 5
else
NewDate = Selection
endif
$ = Num2Date(NewDate, "EEE DD.MM.YYYY")
Hope this helps, too. -
Setting number of days e-mails/messages stay on Z30 device?
I have a z30 and finding that my e-mails that were staying for about 30 days is now only going back a week on those I have received. I remember on my other BB units that I could set them to stay 30, 60 days? I thought I had seen this feature on my Z30 but **bleep** if I can find it. Please tell me where to find it. Thx
Sync interval is how often to sync the mail account with server
sync time frame is what tell device on how long messages stay on device
Click here to Backup the data on your BlackBerry Device! It's important, and FREE!
Click "Accept as Solution" if your problem is solved. To give thanks, click thumbs up
Click to search the Knowledge Base at BTSC and click to Read The Fabulous Manuals
BESAdmin's, please make a signature with your BES environment info.
SIM Free BlackBerry Unlocking FAQ
Follow me on Twitter @knottyrope
Want to thank me? Buy my KnottyRope App here
BES 12 and BES 5.0.4 with Exchange 2010 and SQL 2012 Hyper V -
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. -
FM to get the number of days in Year,month and days by giving number of day
Hi ALL,
This is quit differnt.
I need to give input the 'start date' and the 'number of days' and get the total days from the start date in year,month and day format.
for example.
start date :01.01.2009
number of days as 32
then i should get
years:0
months :1
days :1
Pleas help me out.hi Anusha,
first u pass the date and the days to the following fm you will get the result date....
data:date type sy-datum,
r_date(10) type c.
date = sy-datum.
CALL FUNCTION 'CALCULATE_DATE'
EXPORTING
DAYS = '32'
MONTHS = '0'
START_DATE = date
IMPORTING
RESULT_DATE = r_date
write:/ r_date.
then you need to pass the result date and the date to the following fm to get the required output...
CALL FUNCTION 'HR_HK_DIFF_BT_2_DATES'
EXPORTING
date1 = r_date
date2 = date
IMPORTING
years = v_years
months = v_months
days = v_days
EXCEPTIONS
invalid_dates_specified = 1
OTHERS = 2.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
here u will get the difference in days, months and year...
i hope u wil get help from this...
regards
Ashu Singh -
hai bloggers,
see we have 365 days per year for first half we are going to have 180+ days (if we select first half as the prompt and we select week number as prompt and the last date of that particular week should show in the report)and number of days upto that date or week also should display...if we select second half and week number of that particular half it should show number of days upto that week and highest date of that week number of days should count from 1 to 180+ only mean (july 1 st is 1 st day)
thanksYou need to use timestampdiff function for calculating number of days. One of the way to calculate is like this
case when "Time"."Calendar Half Year" = 1 then timestampdiff(SQL_TSI_DAY,CAST(EVALUATE('TO_DATE(%1,%2)','01-01'||'@{YEAR}{2010}','DD-MM-YYYY') AS DATE),CAST(EVALUATE('TO_DATE(%1,%2)','30-06'||'@{YEAR}{2010}','DD-MM-YYYY') AS DATE)) else timestampdiff(SQL_TSI_DAY,CAST(EVALUATE('TO_DATE(%1,%2)','01-07'||'@{YEAR}{2010}','DD-MM-YYYY') AS DATE),CAST(EVALUATE('TO_DATE(%1,%2)','31-12'||'@{YEAR}{2010}','DD-MM-YYYY') AS DATE)) end
If you want calculate between 1st day of the half and last date of a week then use following
case when "Time"."Calendar Half Year" = 1 then timestampdiff(SQL_TSI_DAY,CAST(EVALUATE('TO_DATE(%1,%2)','01-01'||'@{YEAR}{2010}','DD-MM-YYYY') AS DATE),MAX(MAX("Time"."Calendar Date"))) else timestampdiff(SQL_TSI_DAY,CAST(EVALUATE('TO_DATE(%1,%2)','01-07'||'@{YEAR}{2010}','DD-MM-YYYY') AS DATE),MAX(MAX("Time"."Calendar Date"))) end
Hope it will answer your question
Thanks,
Phani. -
Program or FM to convert number of days into a CalDay format (ddmmyyy)
Hi ABAP friends,
I input calendar day values via a popup calendar from a spreadsheet to BW. So, the values that are populated in BW are the numbers, and not the date.
For ex. when user selects a calendar day for ex. 11-April-2010, the value in excel is stored as 40279 (which is the number of days starting from 01-Jan-1900) and this is the value that gets stored in BW once we save the data.
I'm looking for a function module or method or whatever that converts the above number (40279) into CalDay and writes it to the 0CALDAY infoobject ???
Please help,
Thanks,
VenkatThanks Pranaam.
Two things:
1. I cannot find this FM. It says FM doesn't exist. SE37 --> HR_HK_DIFF_BT_2_DATES
2. My requirement is actually reverse as you explained. I can certainly hard code the starting date: 01011900, but here the input should be the number of days. and I need the date (date2 in your ex.) based on the no. of days entered.
I found another FM which does exist in my BW system. That is: FIMA_DAYS_AND_MONTHS_AND_YEARS
Based on "From" & "To" dates, it outputs the number of days.
But my requirement is:
Based on the starting date (i.e. always 01011900) and number of days, it should give me the "To" date value. -
Current Date plus number of days script
Hi All,
I have a form I am building which has a date field (currently setup to specifiy todays date on load). There is a field that slects number of days until a billing cycle (currently 0 through 13 days).
I need to setup a script that takes todays date, adds the number of days from the 0-13 result and gives a result of a date (0-13 days from today for example).
Any thoughts on how I might do this? Very new to JS.
Thanks for any help you may be able to provide.
Anthere is an example of what I have used:
var f = this.getField("BILLINGCYCLEDATE");
var g1 = this.getField("DAYS");
var g = g1.value
var today = new Date();
var add = d1.valueOf();
add +=1000 * 60 * 60 * 24 * g;
var future = new Date(add);
f.value = util.printd("mm/dd/yyy", future);
You would want to set this up as a calculation in your BILLINGCYCLEDATE field. The field DAYS is whatever you have set up as the 0-13 counter. I set up a simple text box where you input a number. The field will then calculate X number of days out. Hope this helps. -
How to automatically update the Expiry Date's number of days
My web app input form is an event submission form. Users enter the event title, event date and other details, etc. I've figured out how to get the "expiry days" in the form and it be hidden but i can't figure out how to calculate this:
(today's date) - (event date) + 1 day = number of days to expire and then set the expiry days to that value upon submission.
I have tried writing the js but am getting no where, has anyone out there already accomplished this? I've researched and researched and find a million things on calculating the number of days but can't get one of them to work for my situation here... any help would be greatly appreciated!!Hi Murtuza,
You can use function module BAPI_ISUACCOUNT_CHANGE.
Pass dunning lock details in parameter TCTRACLOCKDETAIL. This function module only create and delete locks.
So, you need to pass existing lock details (from table DFKKLOCKS) with PROCESSING_MODE = 04 (delete) and append another value with changed expiry date with PROCESSING_MODE = 01 (Create).
This will also help in maintain lock history too.
Hope this helps.
Regards,
Avinash -
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, -
Customer Exit for Number of Days from 1 st Apr to last date of Month Enter
Hello BI Experts,
I have a requirement to count the number of days from 1 st April of current year to the last date of month entered.
For example : The use will enter say July 2010 or 003.2010 (as Fiscal Year Variant is V3 ).
Today is 14 July ...So we have to first find out the end date of the July month ie 31 st July
Then go to 1 st April 2010.
Now calculate the Number of days between 1 st April to 31 st July 2010.
I consider I have to create two Customer Exit variable
as below
1 st customer exit Bex variable say ZLY_MTH ( Last day of Month Entered)
and i_step = 1
2 nd Customer Exit BEx Formula variable say ZF_NUMDAYS ( Number of days between two dates)
i_step =1 .
Please provide me the logic for the above two.
Thanks in Advance.
Regards,
Amol KulkarniPSUDEO CODE:
1. Initially LOOP AT I_T_VAR_RANGE INTO LOC_VAR_RANGE WHERE VNAM = 'ZMONTH'.
2. Get the Month input using VAR_MONTH2 = LOC_VAR_RANGE-LOW+4(2)
3. Now calculate Month+1: VAR_MONTH2 = VAR_MONTH2 + 1 (Refer **)
4. Now calculate the Current Year: VAR_YEAR = LOC_VAR_RANGE-LOW+0(4).
5. Get the 1st Day of the Month (VAR_MONTH2): CONCATENATE '01' '/' VAR_MONTH2 '/' VAR_YEAR INTO L_S_RANGE-LOW.
6. SUBRACT 1 (0DATE) from this DATE (This will give the logic for last day of the current month)
Insert this code also for using the date conversions
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
INPUT = VAR_MONTH2
IMPORTING
OUTPUT = VAR_MONTH2.
Pls. check out this logic. Guess it would solve your need.
Thanks,
Arun Bala -
How do you work out the number of days difference between two dates?
I'm running Crystal v12.
We use a date field in our SQL database that we use to store the client's year end date.
As the year end date (date and month) doesn't change for a client, the year end date field in all of our reports is set to just show the DD/MM part. Over the years as new clients are set up we just enter the date and month - the year part is irrelevant although as in all date fields the year is automatically entered.
Doing it this way means that we don't have to adjust the year end year part each year. We just use the DD/MM part.
I need to create a formula that works out the number of days there have been (i.e. the difference) from the current date to the year end date. It MUST EXCLUDE the year however.
For example:
Year End Date = 30/04/03
Current Date = 25/05/10
Days Difference (EXCLUDING year) = 25
Days Difference (including year) = 2582
Year End Date = 31/03/09
Current Date = 25/05/09
Days Difference (EXCLUDING year) = 55
Days Difference (including year) = 420
If you include the year part then working out day difference is simply a case of creating a formula that subtracts the year end date from the current date (CurrentDate - {tblClient.YearEnd}.
HOWEVER I need to exclude the year part.
Can anyone tell me the formula or best way to do this?
Thanks in advance.
Edited by: BadBoy House on May 25, 2010 3:15 PM
Edited by: BadBoy House on May 25, 2010 3:15 PMHi
You can try this
datevar e := date(year(currentdate),month({tblClient.YearEnd}),day({tblClient.YearEnd}));
numbervar num_days := datediff("d",currentdate,e)
Create a datevar called e that uses the original month and day numbers for {tblClient.YearEnd} but uses the year of the current date
Then just datediff on e to get the number of days between the two dates
I hope i understand your problem and that this helps
Best regards
Patrick -
How to calculate the days between last movement of material till today date
Hello Experts,
Could someone help me please?
I have a key figure in the InfoCube 0IC_C03 witch contain the last date of movement of material.
(it is a key figure created in format date and contain the max value).
How can I to calculate the number of days between this date (last movement), till today date (system date).
I need to show:
material........last movement.....days without movements.
xxxxxxxxxxx.....dd/mm/yyyy..........9999
Im trying to do this calculation in bex using variable formula but it doesn't work becouse current date (customer exit) brings sy-datum in format yyyymmdd and the kf-last-mov is in format number (I dont know what kind of number)
Thanks in advance,
Points are assured.
Regards,
Silvio Meurer.
Message was edited by:
Silvio MeurerHi Parth,
Here we are using the version 7.0 and SP 10, I'm afraid I could not understand you. I Can't find the function DATE_DIFF (Where is it?)
I'm using the formula and it doesn't work. Coud you see the result is:
last movement date Today date result
02.04.2007 20.070.625 19.337.856
18.05.2007 20.070.625 19.337.810
the "today date" is from customer exit and the result is a strange number to me.
Could you help me? -
How can I calculate the maximum number of days between two dates in a range of dates?
I have a column of dates spanning the couse of a few months. I would like to know if I can calculate the maximum number of days between each row and display the highest number. I currently have another column that calculates the days betwen the rows and I am currently just looking at the totals and highlighting the highest period.
Is this possible? Any help or suggestions are appreciated.
Thank you,
TrevorThis sounds totally possible, Can you post a screen shot of your table to make responding more focused? If you mean you want to:
A) compute the difference (in days) between two date in the same row, then
B) find the max duration (in days)
Here is my take on this problem:
D2 = C2-B2
select D2 and fill down
F1=MAX(D)
to perform the conditional formatting (to highlight the max duration) select column D, then set up conditional formatting as shown in the 1st image
Maybe you are looking for
-
In iOS6 text message previews would be shown in the notification center when the phone was unlocked and would just show up as "text message" or "imessage" in the lock screen...is there a way to change it so it's the same in iOS7? currently with "no p
-
Liner notes without digital booklet?
I've just purchased the new Cat Power album through iTunes. I know only through my own familiarity with some of the songs, and through reviews, that almost all of them (which are absolutely incredible) are covers. But there's no metadata telling me w
-
Problem installing CS5 and CS6 on new imac i5 2013
exit error 15 "incoerenze nel database d'installazione"
-
hi, I"m working on the program that's similar to paint, and I would like to place my contentPane to be at the specific location (for the drawing area). Is there anyway, rather than BoxLayout, FlowLayout, or GridLayout to set the location of the JPane
-
My Macbook Pro has been having issues. When I'm on Chrome, parts of the browser will suddenly have chunks missing and show my desktop. I took it to the Genius bar and they sent it out to have the logic board replaced, but I am still having the issue.