RE: Length of smallint field
- From: "Everett Mills" <eemills@xxxxxxxxxxxxxxxx>
- Date: Thu, 11 Sep 2008 14:10:59 -0500
Most Informix data types have implicit casts to character types and vice
versa, so there is no special command, just LET. This is an easy way
using a smallint value. I think you'd be better off using the DATETIME
HOUR TO MINUTE data type, but here's a smallint version:
DATABASE sample
MAIN
DEFINE
my_char CHAR(4),
my_int SMALLINT
LET my_int = 600
LET my_char = my_int USING("&&&&")
DISPLAY my_char
END MAIN
This prints out: 0600
This is the datetime version. Note that the data type would prevent
invalid times from being entered, so you wouldn't have to check them as
rigorously.
DATABASE sample
MAIN
DEFINE
my_char CHAR(4),
convted CHAR(5),
my_time DATETIME HOUR TO MINUTE
LET my_time = "06:00"
LET convted = my_time
LET my_char = convted[1,2], convted[4,5]
DISPLAY my_char
END MAIN
This also prints out: 0600
--EEM
-----Original Message-----.
From: informix-list-bounces@xxxxxxxx [mailto:informix-list-
bounces@xxxxxxxx] On Behalf Of monkeys paw
Sent: Thursday, September 11, 2008 10:26 AM
To: informix-list@xxxxxxxx
Subject: Re: Length of smallint field
Is there a function that will convert a smallint (600)
to the char string "600", which i can then preceed with
zeros?
Ian Michael Gumby wrote:
On Sep 10, 3:18 pm, monkeys paw <u...@xxxxxxxxxxx> wrote:_______________________________________________
I have a table with a smallint field. A number is entered into
a 4gl form. I need it to be 0 padded, four digits wide. however,
the LENGTH() function doesn't work on smallint fields. So whether
user enters "600" or "0600", the length call below returns 0.
How can i get around this, i need it entered in military time
by the user, they must enter preceeding zero if time is less
that 1000, like "0900".
let len = length(calRec.hearing_time)
message len
Wow, an account that has been banned by Google for a TOS violation.
Everett has it right. If you're using a field to enter time in a
"military" fashion, use characters.
Then use your after field statement to validate the entry. If a non
numeric is entered then you can
fix it. If they enter 6:00 you can update it to mean 06:00.
If you need to do any calculations, you can strip leading 0's and or
whitespace and then convert to a number and perform calculations.
Informix-list mailing list
Informix-list@xxxxxxxx
http://www.iiug.org/mailman/listinfo/informix-list
- References:
- Length of smallint field
- From: monkeys paw
- Re: Length of smallint field
- From: Ian Michael Gumby
- Re: Length of smallint field
- From: monkeys paw
- Length of smallint field
- Prev by Date: Re: Length of smallint field
- Next by Date: For fans of GUI tools
- Previous by thread: Re: Length of smallint field
- Next by thread: Re: Length of smallint field
- Index(es):
Relevant Pages
|