on 09-03-2020 6:47 PM
I have a field that is date time field, using that field I need to determine what shift a person worked.
I was thinking about using an IF statement to determine based on the time, what shift a person worked.
I used this formula to convert the field to Time
TimeValue ({lwmain.dtrepor})
Then I tried to write an IF statement to determine the shift. This is a separate formula from the above. Or maybe it should all be one statement.
IF {lwmain.dtrepor} between 06:00 to 13:59 then "I" or
IF {lwmain.dtrepor} between 14:00 to 21:59 then "II" or
IF {lwmain.dtrepor} between 22:00 to 23:59 then "III" or
IF {lwmain.dtrepor} between 00:01 to 05:59 then "III"
But it errors out and I am unsure how to make it use the time only and then do the If then statement.
Any help is appreciated.
Try:
IF Time ({lwmain.dtrepor}) = CTime("06:00") to CTime("13:59") then "I" else...
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thank you for your response. Here is what I attempted:
IF Time ({lwmain.dtrepor}) between CTime("06:00") to CTime("13:59") then "I" or IF Time ({lwmain.dtrepor}) between CTime("14:00") to CTime("21:59") then "II" or IF Time ({lwmain.dtrepor}) between CTime("22:00") to CTime("05:59") then "III" Else {lwmain.dtrepor}
I get an error that highlights the first between and says it expects a then
Ideas
You can't use "or" between If..then statements, Instead, you have to use "else", like this:
IF {lwmain.dtrepor} = CTime("06:00") to CTime("13:59") then "I"
Else IF {lwmain.dtrepor} = CTime("14:00") to CTime("21:59") then "II"
Else IF {lwmain.dtrepor} = CTime(22:00") to CTime("23:59") then "III"
Else IF {lwmain.dtrepor} = CTime(00:01") to CTime("05:59") then "III"
Or you could use a Switch statement like this:
Switch
(
{lwmain.dtrepor} = CTime("06:00") to CTime("13:59"), "I",
{lwmain.dtrepor} = CTime("14:00") to CTime("21:59"), "II",
{lwmain.dtrepor} = CTime(22:00") to CTime("23:59") "III",
{lwmain.dtrepor} = CTime(00:01") to CTime("05:59") "III"
)
Either one of these should work for you.
-Dell
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
89 | |
10 | |
9 | |
9 | |
9 | |
6 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.