I have got a start date and end date in this custom format
dd.mm.yyyy hh:mm in excel cells.
What i need is to fill specific row with dates incremented by half hour from start date to end date using VBA code. And i havent got any idea how to do this.
On web there are some examples with similar problems but with only months or only hours and those are dates format not custom.
You can do this with a simple formula.
Write your start date into cell A1
In A2 write =A1+(1/48)
Copy formula from A2 down
done.
How does this work?
Excel dates are represented as count of days since 1900. That means 1900-01-01 is the first day and represented by 1. All other dates are just the count of days since then. 1 represents one day. So since 1 day has 24 hours 1/48 represents half an hour.
The number format dd.mm.yyyy hh:mm how Excel shows the date is not relevant, because Excel only saves the value (amount of days since 1900) in the cell value.
So if you type the date of today into a cell 2018-10-11 Excel actually saves 43384 in the cell value (today it is 43384ᵗʰ day since 1900-01-01).
One option is to find the interval between start and stop point. Remember that excel dates that are actually dates and not strings are actually integers. The second thing to remember is time is the decimal part which represent fraction of a day. Test if your date (assuming it's in A1) is an actual date or a string with
=ISNUMBER(A1)
If that comes back TRUE you do not need to worry about converting your date. If it comes back FALSE, its actually a string and will need to be converted for excel to work with it.
Divide this interval by 30 minutes, or 30/60/24 to and add 1. This will tell you how many iteration you will need which you can put into a For loop
Start_Number = Range("A1")
End_number = Range(("A2")
Stamp = Start_Number
Interval_number = End_Number - Start_Number
Counter = integer of (Interval_number / (30/60/24))
For x = 1 to counter
write Stamp to cell
Stamp = Stamp + 30/60/24
Next x
Allternatively you could set up a while loop.
Do While datetime < Stop_Point
Write datetime to cell
Datetime=datetime + 30/60/24
Loop
Please note, not actual code but giving idea where OP had no idea where to start.
Related
I'm struggling to make a formula work in excel.
My case : I have data in m/d/yyyy h:mm AM/PM format on E col.
I have data that goes to the next day post midnight. I'm looking to create another column lets say F where I want to check for data between time 5:30pm to next day 5:30am and return date in m/d/yyyy(col F)
Example :
Let's say a job request came in at 3/21/2021 4:30am, I want it to return 3/20/2021 on col F (previous date)
This is required due to different timezone and unfortunately the timezone cannot be altered on the data.
If it's really true that your data are in "m/d/yyyy hh:mm PM format" then this formula will deduct 8 hours from the value found in E4 and return a true date.
=DATE(RIGHT(LEFT(E4,FIND(" ",E4)-1),4),LEFT(E4,FIND("/",E4)-1),MID(E4,FIND("/",E4)+1,1+ISERROR(FIND("/",MID(E4,LEFT(E4,FIND("/",E4)-1),2)))))+TIMEVALUE(MID(E4,10,10))-(8/24)
A "True" date is a number which takes its display format from the cell format you set, meaning the "data" are different from the display. A "Fake" date (my expression) is a text string that looks like a date but is unsuitable for calculations because it's not a number. The "data" underlying a fake date are identical to the display. My above formula spends 95% of its effort on converting the fake date into a true one and is likely to earn your comment that it "doesn't work" because it returns a number. If so, don't comment. Set the cell format to the kind of display you want.
Of course, if E4 has a true date the effort can be reduced and the formula you seek would be simply
=E4-(8/24)
This is because in Excel dates one day has a value of 1. Therefore 1 hour = 1/24 and 8 hours = 1/24*8 or 8/24. Change the number of hours as desired, add or subtract them from the original as needed.
BTW, if your original data are really text (fake dates) do consider converting them to true dates using the 95% part of my first formula and then processing them as true dates. As you see, there is no advantage in keeping fakes around.
I have a column "cycle time" with hh:mm:ss value format. I want to count the number of cells on the column which has the value of lesser than or equal to "04:00:00".
My below formula returns "0" value instead of "4". Here's the column values
and my formula is =COUNTIF('sheet1'!I:I,"<= 4:00:00")
Can anyone share me how to solve this?
Basic unit in date and time is one day is 1. So a fraction of a day represents time.
One day is 24 hours, so 4hs is 1/24 * 4=0.16666667
=COUNTIF('sheet1'!I:I,"<=0.16666667")
I recommend you save this value in a cell, i.e. P1=4/24
=COUNTIF('sheet1'!I:I,"<="&P1)
And also, as #Jeped commented, using TIME funciton:
=COUNTIF('sheet1'!I:I,"<="&TIME(4, 0, 0))
I am trying to take the values of time passed (formatted HH:MM:SS) and convert it to just minutes.
The issue I am having is that when I try and get the value of the time-value cell, it converts it to some odd value.
Example:
Wrong Value (what Excel gives me now, in worksheet):
34:32:12 = 1.43902777777778
Right Value (what Excel should give me):
34:32:12 = 2072.2
Calcualted:
34*60 + 32 + 12/60
Assuming your source value is in cell A1, here is all you need:
=N(A1*1440)
This method does not require a reformatting of the output cell.
How does it work?
Dates and times are stored in Excel as a combined number... where the integer portion represents the number of days since December 31, 1899 (although the year that Excel calculates from can be changed to 1904 in the Excel Options, but that is immaterial).
The decimal portion of the stored number represents the time component to associate with the date.
Your value of 1.43902777777778 is correct. It states that the ~34.5 hours represents ~1.44 days.
Since you are interested in minutes, we convert that days figure to minutes by multiplying by 1440 as there are 1440 minutes in a day.
The N() function that wraps that calculation ensures that the displayed output is treated as numeric by Excel. Otherwise the output cell would adopt the date-formatting of A1.
Either format the cell as [m] to see 2072, or multiply by 1440 (the number of minutes in a day) and format as 0.0 to see 2072.2
i need an excel formula to calculate the total days remaining for a cell: end date minus todays date plus extension days(maybe 30-90 amount is in a cell) i have tried =days360(today's date,end date + number of extension days) in a different cell but it isn't giving me the correct total
It's giving me the wrong amount of days. I have a formula calculating my end date as well, is that causing a problem =SUM(start date+90+#of extension days)
One possible reason could be your usage of the DAYS360 formula. That uses a 360-day calendar and assumes all months are 30 days. Therefore if you are covering a range where this would have an effect, you will see a difference. For example, with the range 1/1/2013 to 6/1/2013, subtracting the two dates returns 31+28+31+30+31 = 151, compared to DAYS360, which returns 30*5 = 150.
Try just doing basic subtraction, which will also work on dates:
=<End Date> - TODAY() + <Extension>
Is there a way to convert the below Excel formula to a query/criterion in Access?
L2 = Date
J2 = Another Date
Z1 = Todays Date
I think it is calculating the number of days in between two dates but not sure how to do this in an Access query.
IF((AND((L2<1),(J2>1))),(NETWORKDAYS(J2,$Z$1)-1),0)
As you may by now have gathered, the question does not really make sense. NETWORKDAYS does indeed calculate the number of “whole working days excluding weekends and any dates identified in holidays” between two dates (here whatever date is in J2 and whatever is ‘Today’/Z1) and IF makes that calculation contingent upon the result of the AND function being TRUE. The AND function results in TRUE provided both the ‘date’ in L2 is before 1/1/1900 and the date in J2 is after 1/1/1900 (because to Excel 1/1/1900 is Day 1 where dates are concerned [unless one opts for the 1904 date system]).
But Excel does not recognise a date before Day 1, whether a negative number or a decimal number. For example Day 1.5 is noon on 1/1/1900 whereas in the same format Day 0.5 shows as 0/1/1900.
So in essence, L2 is not a date of any real use to the formula, hence I believe why no answer yet to your question. But this is too long to fit in a comment hence my answer: “No.”!
Set a reference to Excel.
Option Compare Database
Private Sub Command2_Click()
MsgBox GetNetWorkDays(#1/29/2017#, #2/8/2017#)
End Sub
Function GetNetWorkDays(startDate As Date, endDate As Date) As Integer
GetNetWorkDays = WorksheetFunction.NETWORKDAYS(startDate, endDate)
End Function
Put the button on a Form and click the button!
If you want to calculate number of days between days than you can use below built in function "DateDiff" which will solve it out. Datediff("D",,)
Ex. Datediff("D",L2,Z1)