Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Get Types::Time from anyType

28 views
Skip to first unread message

Richard

unread,
Jul 12, 2010, 9:37:10 AM7/12/10
to
Hi All,

Anyone know how to determine a field is of type Types::Time?
I have a database field of type Time witch has an EDT "timeOfDay"

When i try to check for the datatype of the field (actualy a variable af
anytype that represends the data from the field) it returns int as the type.
I want to know when the type is either Types::Time or the base EDT of the
EDT is "timeOfDay"

The complete function:
static str getFieldDataString(Common common,SGCKeyWord sgcKeyWord)
{
Name name = sgcKeyWord.Name;
anytype data = common.(sgcKeyWord.Field);
str value;
BinData binData;
Types type = typeof(data);
;

//transfer generic data to string value
switch( type )
{
case Types::Container://containers are transferred to a base64 string
binData = new BinData();
binData.setData(data);
value = binData.base64Encode();
break;
case types::Enum:
value = enum2str( data );
break;
case types::UtcDateTime:
value = DateTimeUtil::toStr( data );
break;
case types::Time:
value = time2str( data, 0, 0);
break;
default:
value = String::replaceXmlChars(data);
break;
}

return value;

}

the tricky part:
case types::Time:
value = time2str( data, 0, 0);
break;


amir nazim

unread,
Jul 13, 2010, 5:30:58 AM7/13/10
to
Hi Richard,

this is bit tricky, try below job, may be this helps you.
static void Job1(Args _args)
{
// Edt TimeHour24 extends with timeOfDay
SysDictField obj1 = new
SysDictField(tablenum(Table1),fieldNum(Table1,TimeHour24));
SysDictType obj2 = new SysDictType(obj1.typeId());

print obj1.typeId();// its give EDT it
print obj2.isTime(); // its give you true
pause;
}

Thanks
Amir
http://msdax.wordpress.com/
m.ami...@gmail.com

Richard

unread,
Jul 14, 2010, 11:39:25 AM7/14/10
to
Hi Amir,

This definitely helped me.
I find it odd that the basetype is not of Types::Time.
In morphx at the property window it is defined as being of type Time...
Why is the enum value even there to choose from?

Anyway this workaround is perfect,thanx a lot!

greetings Richard

0 new messages