Need Help with Formula for input text when meeting Criteria

Discuss the spreadsheet application
Post Reply
hammerhead13
Posts: 43
Joined: Sat Jan 12, 2013 11:09 pm

Need Help with Formula for input text when meeting Criteria

Post by hammerhead13 »

I would like for C6 to say "Lunch" if C2 is less than 30min and after that passes C6 to Say "End of Day" if C4 is Less than 30 min. Thank you in advance for the help!


A B C
1 Break 10:00:00 AM
2 Lunch 12:30:00 PM 19:38
3 Break 04:30:00 PM
4 End of Day 05:30:00 PM 00:38
5
6
Attachments
Example.ods
(8.75 KiB) Downloaded 120 times
OpenOffice 3.1 on Windows 7 Ultimate 64Bit
jeffs12
Posts: 42
Joined: Wed Mar 19, 2008 9:48 pm

Re: Need Help with Formula for input text when meeting Crite

Post by jeffs12 »

What you're probably looking for is a "nested IF" function. Something like

=IF(C2<30;"Lunch";IF(C4<30;"End of Day";"Neither"))

But before that will work, you'll need to fix the formulas in C2 and C4. You're trying to subtract a date value (the result of the NOW() function) from a time value which is yielding a negative number. Change the format of those cells to 'number' to see what the real result of those formulas are.
AOO 4.1.13 on M$ Windows 7/10/11
User avatar
soby
Volunteer
Posts: 150
Joined: Sat Oct 29, 2016 10:49 am

Re: Need Help with Formula for input text when meeting Crite

Post by soby »

a word off advice don't use the now() function for calculating working hours
Libre Office 6.1 dev homebuild Open Office 4.1.5 on Slackware64 current
hammerhead13
Posts: 43
Joined: Sat Jan 12, 2013 11:09 pm

Re: Need Help with Formula for input text when meeting Crite

Post by hammerhead13 »

Thank you for the Help. What would be the Best way to capture the current time other than Now()?
OpenOffice 3.1 on Windows 7 Ultimate 64Bit
User avatar
Lupp
Volunteer
Posts: 3755
Joined: Sat May 31, 2014 7:05 pm
Location: München, Germany

Re: Need Help with Formula for input text when meeting Crite

Post by Lupp »

=MOD(NOW();1) will cut off the integer part coding for the date. The reminder returned by MOD is the TOD expressed as the respective fraction of a whole day.
On Windows 10: LibreOffice 25.8.4 and older versions, PortableOpenOffice 4.1.7 and older, StarOffice 5.2
---
Lupp from München
hammerhead13
Posts: 43
Joined: Sat Jan 12, 2013 11:09 pm

Re: Need Help with Formula for input text when meeting Crite

Post by hammerhead13 »

Im not sure but this doesnt seem to be working correctly. I tried changing the format but it is not changing no matter what time i use
OpenOffice 3.1 on Windows 7 Ultimate 64Bit
User avatar
Lupp
Volunteer
Posts: 3755
Joined: Sat May 31, 2014 7:05 pm
Location: München, Germany

Re: Need Help with Formula for input text when meeting Crite

Post by Lupp »

You obviously try to calculate in C2 (e.g.) the time passed since the start of lunch for the current day. Regarding this intention the SIGN of your difference is wrong from the beginning: Even if NOW gave the correct time it was negative after lunch start and positive before.
Start woking with

Code: Select all

=MOD(NOW();1)-B2
in C2 and refine your conditions (positive but less than 00:30:00 e.g. for the short lunch).
As long as the time values are actually numbers (not text) the calculated results never depend on the formats you chose. The only problem with formats is that thay may lie to your face. This will not afflict, however, any conditions based on the values gotten from the respective cells.

(Editing:)
I would prefer a solution like demonstrated in the attached.
Attachments
ask86921StatusWithinaWorkday_1.ods
(12.21 KiB) Downloaded 121 times
Last edited by Lupp on Sat Jan 14, 2017 4:37 pm, edited 1 time in total.
On Windows 10: LibreOffice 25.8.4 and older versions, PortableOpenOffice 4.1.7 and older, StarOffice 5.2
---
Lupp from München
Post Reply