cancel
Showing results for 
Search instead for 
Did you mean: 

SAPbobsCOM.Recordset Date time

former_member306083
Participant
0 Kudos

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;
}

Accepted Solutions (1)

Accepted Solutions (1)

edy_simon
Active Contributor

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

former_member306083
Participant
0 Kudos

Thank you!

Answers (1)

Answers (1)

ANKIT_CHAUHAN
Product and Topic Expert
Product and Topic Expert

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

former_member306083
Participant
0 Kudos

Thank you for your help!

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

All the best

ANKIT_CHAUHAN
Product and Topic Expert
Product and Topic Expert
0 Kudos

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