which search function will convert 8:30 to a numbe...
# suitescript
a
which search function will convert 8:30 to a number?
I've tested TO_NUMBER and TO_NUMBER(TO_CHART(()) and it didn't work
b
what number would you want it to be
a
@battk float number
8.5
b
you would need to split it into 2 strings
and then add them
a
how can I do that inside search
I want to compare it with another number
and if it's bigger show the result
I want to compare it with another number as a search criteria
b
TO_CHAR would be my choice
a
I've used TO_NUMBER(TO_CHAR(field))
<other field
but didn't work
TO_CHAR will convert it to text but I need to compare numbers
b
use TO_CHAR with the appropriate Datetime Format Models
then you can convert it to a number
a
@battk I don't think there is something on the above link that can help with converting 8:30 to 8.5
at least I can't see
b
convert it to 8 and 30
divide 30 by 60 and add it to 8
a
is it possible to do this in the search formula?
according to this link
Copy code
TO_NUMBER(TO_CHAR({hours}))
should work but it didn't
I can use your solution outside search but I'm not sure how to do it in the search formula
b
step one, make your formula get the minutes
you have to use the fmt parameter of TO_CHAR
a
is there somewhere that I can test these format models
b
you can try searching online for things to run sql online
i dont think it will be any better than simply making a text formula with whatever formula you want
a
@battk I've tested some of them but the issue is there is no fmt for 8:30 in that link
how can I simply make a text formula
b
you will be using TO_CHAR twice
once for the minutes, once for the hours
dont try combining them
a
yes that's correct but I can't get the result for them
I can't find the correct fmt parameter
b
what have you tried
a
:
99.99
99:99
:MI
MI
b
that last one should work
a
no it didn't
b
whats your full formula
a
TO_CHAR({hours}, 'MI')
ERROR: Invalid Expression
b
and which record is being searched
a
timebill
b
that might not actually be time of day
a
I think that's not
b
treat it as a string then
a
ok
b
the hours is everything upto the
':'
minutes everyhing after the
':'
a
what function can help
inside the formula
b
INSTR in combination with SUBSTR
a
is there a list of functions with details
b
you can cut it down to REGEXP_SUBSTR if you want to use a regular expression
a
Thanks