I'm new into coding.
I'm using the echo %time% to get the time.
Now is my goal to add 4 hours to this time and create the output.
Nice would be to have the time only in hours and minutes.
It would help to tell you are working on a batch script, makes helping easier
You can split up the time in hours and minutes:
set hh=%time:~0,2%
set mm=%time:~3,2%
and add 4 hours:
set /A hh=%hh%+4
then concat them back together, and do not forget to fix it when the hours go above 24, a simple if statement would do fine then distract the 24 to get the right time
Related
I need create an empty loop that runs for a given time, for example 2 hours. The loop just runs for nothing, no matter what it does, it is important that it loads R executions for exactly 2 hours.
for example, let's have some kind of script
model=lm(Sepal.Length~Sepal.Width,data=iris)
after this row there is an empty loop that does something for exactly 2 hours
for i....
after the empty loop has completed via 2 hours, continue to execute subsequent rows
summary(model)
predict(model,iris)
(no matter what row, it is important that in a certain place of code the loop wasted for 2 hours)
How it can be done?
Thanks for your help.
There is no need to do this using a loop.
You can simply suspend all execution for n seconds by using Sys.sleep(n). So to suspend for 2 hours you can use Sys.sleep(2*60*60)
i have a problem in MS Project 2013:
i´d like to set up a work package that has a certain duration but in this duration there is no work like 8 hours x (duration in days) required but e.g. 5 days of work in a timeframe of 30 days.
this is annoying to set up but it works. now ms project does not draw the respective bar for 30 days of duration but only for 5 days (the work). at the end of the bar a little arrows goes on for another 25 days (resulting in 5+25=30days) and then turns down to the next work package. i´d rather like to see a bar for the full 30 days and then for the arrow to go down.
is there a way to do this?
it seems wrong that the bar depends on the work rather than the duration because it is not likely that the work gets done in the first 5 days and then you just wait for 25 days.
Create a new task and set the Duration to 30d and make sure the type is "Fixed Duration" and set the task's Work to 40h.
I'm facing difficulties to show the time time difference in hours where hours are greater than 24.
Right now I'm using the following in iReport
(new SimpleDateFormat("dd':'HH':'mm':'ss")).format(new Date($V{avgDuration}.longValue()*1000))
where $V{avgDuration} is a variable in jrxml file which is the average time difference between two dates in seconds. Here it shows the 1 day 1 hour but I want it to be 25 hour. What should I do?
I've solved the problem using PeriodFormatterBuilder. But for this, I need to use joda-time library.
In the expression editor of the text box in jrxml file, just wrote the following:
new org.joda.time.format.PeriodFormatterBuilder()
.printZeroAlways()
.minimumPrintedDigits(2)
.appendHours().appendSeparator(":")
.appendMinutes().appendSeparator(":")
.appendSeconds()
.toFormatter()
.print(new org.joda.time.Period(
$V{avgDuration}.longValue()*1000))
I have an Excel table which contains thousands of incident tickets. Each tickets typically carried over few hours or few days, and I usually calculate the total duration by substracting opening date and time from closing date and time.
However I would like to take into account and not count the out of office hours (night time), week-ends and holidays.
I have therefore created two additional reference tables, one which contains the non-working hours (eg everyday after 7pm until 7am in the morning, saturday and sunday all day, and list of public holidays).
Now I need to find some sort of VB macro that would automatically calculate each ticket "real duration" by removing from the total ticket time any time that would fall under that list.
I had a look around this website and other forums, however I could not find what I am looking for. If someone can help me achieve this, I would be extremely grateful.
Best regards,
Alex
You can use the NETWORKDAYS function to calculate the number of working days in the interval. Actually you seem to be perfectly set up for it: it takes start date, end date and a pointer to a range of holidays. By default it counts all days non-weekend.
For calculating the intraday time, you will need some additional magic. assuming that tickets are only opened and closed in bussines hours, it would look like this:
first_day_hrs := dayend - ticketstart
last_day_hrs := ticketend - daystart
inbeetween_hrs := (NETWORKDAYS(ticketstart, ticketend, rng_holidays) - 2) * (dayend - daystart)
total_hrs := first_day_hrs + inbetween_hrs + last_day_hrs
Of course the names should in reality refer to Excel cells. I recommend using lists and/or names.
I need to test my C++ program, which uses system time.
The program is large and it uses third party libraries which possibly also use system time.
I want to see how my program behaves for different dates / times.
Is it possible to change the system time only for one running process in UNIX?
Many thanks...
Well, I found the answer by myself.
In unix shell there is an environmental variable TZ which is the timezone and it is used by all C/C++ time functions.
This variable can be manipulated to set time in current unix shell to any arbitrary time (limited to number of seconds, not milliseconds) and even change date.
Examples:
export TZ=A-02:10:20
(shifts time by 2 hours 10 minutes and 20 seconds from now forward).
export TZ=A+02:10:20
(the same shift backwards)
If you want to change the date, you can use large number of hours, for example:
export TZ=A-72:10:20
Unfortunately it does not let you change date too much, from my experiments it is up to several days back/forward. So for changing month/year this does not work.
(use 'date' command to check current date/time after setting TZ variable).
To cancel all changes use
export TZ=
I guess you can use libfaketime.