Skip to Content
0

SAPbobsCOM.Recordset Date time

Apr 07, 2017 at 01:56 PM

156

avatar image
Former Member

Hi, I´m trying to retrieve the date and the time from a database field, but I only get the time (my code below), the result in the SQL manager si '2017-04-06 19:38:05.000' but my recordset is '2017-04-06 00:00:00.000'

SAPbobsCOM.Recordset oRecordSet = oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.BoRecordset);
string sSql = "SELECT MAX([U_FecAct]) AS [U_FecAct] FROM [@TDGIMON]";
oRecordSet.DoQuery(sSql);
if (!oRecordSet.EoF)
{
   DateTime dt = oRecordSet.Fields.Item("U_FecAct").Value;
}
10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

2 Answers

Best Answer
Edy Simon Apr 10, 2017 at 12:49 AM
1

Hi Sebastian,
It is by design. If you notice, SBO system columns keep date and time in 2 different columns.
You may have update your UDF using SQL queries. This is not supported by SBO.
If you want to follow SBO rules, create 2 columns for it, one of type date, another of type time.
If you keep it under current design, you can get the time by Casting the column to string first.

Regads
Edy

Show 1 Share
10 |10000 characters needed characters left characters exceeded
Former Member

Thank you!

0
ANKIT CHAUHAN
Apr 07, 2017 at 02:48 PM
1

Hi,

Try to TypeCast your Variable 'dt'. The below code is working for me:

SAPbobsCOM.Recordset oRecSet = (SAPbobsCOM.Recordset)oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.BoRecordset);
string str = "Select DocDate from ORDR";
oRecSet.DoQuery(str);
DateTime dt = Convert.ToDateTime(oRecSet.Fields.Item("DocDate").Value);

Kind regards,

ANKIT CHAUHAN

SAP SME Support

Show 2 Share
10 |10000 characters needed characters left characters exceeded
Former Member

Thank you for your help!

Same result, I need the time, this only get the date.

All the best

0

Hi Sebastian Pereira Cendan,

I am really sorry and I completely misread it...

As far as I have tested it now, there seems to be no possibility to get it directly in the Recordset. I am afraid that it could be because of design behavior.

Still, I think there might be something in SQL Queries or .NET that could help you to get it done in easy way.

Kind regards,

ANKIT CHAUHAN

SAP SME Support

0