cancel
Showing results for 
Search instead for 
Did you mean: 

How Can I display date in filed of date in SAP B1 SDK?

former_member183402
Participant
0 Kudos

Hi all,

I know how to display value in field of matrix in SAP B1 SDK, but I tried to display date in date field I failed, Below is my code I tried but there is no luck

mtx2.Columns.Item("C_1_5").Cells.Item(mtx2.RowCount).Specific.string = FromDate 'this is variable of date from database

Above codes fail when I run

or

mtx2.Columns.Item("C_1_5").Cells.Item(mtx2.RowCount).Specific.string = Format(FromDate, "dd/MM/yyyy")

Above codes display nothing in the field

Please anyone can help me

Accepted Solutions (1)

Accepted Solutions (1)

former_member183402
Participant
0 Kudos

Hi all,

It works, I took normal field in my query and then I converted variable instead of converting field in query

Thank you

Answers (2)

Answers (2)

former_member595093
Participant
0 Kudos

Pls Replace

Services.GetCompany

with

(Application.SBO_Application.Company.GetDICompany as SAPbobsCOM.Company)
former_member595093
Participant
0 Kudos

I use that code for this. You must replace "Services.GetCompany" with your code.

public static DateTime DateTimeValue(string DateString)
{
    SAPbobsCOM.SBObob oBridge = 
        (SAPbobsCOM.SBObob)Services.GetCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.BoBridge);
    return (DateTime)oBridge.Format_StringToDate(DateString).Fields.Item(0).Value;
}
public static string DateTimeToString(DateTime Date)
{
    SAPbobsCOM.SBObob oBridge = 
        (SAPbobsCOM.SBObob)Services.GetCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.BoBridge);
    return oBridge.Format_DateToString(Date).Fields.Item(0).Value.ToString();
}
public static string DateTimeToString(object Date)
{
    SAPbobsCOM.SBObob oBridge = 
        (SAPbobsCOM.SBObob)Services.GetCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.BoBridge);
    return oBridge.Format_DateToString((DateTime)Date).Fields.Item(0).Value.ToString();
}
former_member183402
Participant
0 Kudos

Hi Hakan,

Actually FromDate is selected from database with recordset

                                Dim sRs As SAPbobsCOM.Recordset = oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.BoRecordset) sRs.DoQuery("SELECT T0.[U_FromDate] from [dbo].[@ODDS]  T0...........")

Data type of U_FromDate is date

variable of U_FromDate which is FromDate is the one used below

mtx2.Columns.Item("C_1_5").Cells.Item(mtx2.RowCount).Specific.string = FromDate

I tried to use

Dim sRs2 As SAPbobsCOM.SBObob = CType(Services.GetCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.BoBridge), SAPbobsCOM.SBObob)

But I get error message Addon failed.... to that line