Skip to Content

SAPbobsCOM.Recordset Date time

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;
}
Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

2 Answers

  • Best Answer
    Apr 10, 2017 at 12:49 AM

    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

    Add comment
    10|10000 characters needed characters exceeded

  • Apr 07, 2017 at 02:48 PM

    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

    Add comment
    10|10000 characters needed characters exceeded

    • 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