How to pass the date to day, month and year in C#?

Asked

Viewed 127 times

1

I need to pass my dates for day, month and year in Brazilian format, but I searched the code and the internet and I do not know apply the examples to my problem.

inserir a descrição da imagem aqui

It returns the results so I need to return in the dd-MM-yyy format.

Follows the source:

protected override void DefineGridDataSource(IGrid grid, string processParam)
    {
        string[] separator = new string[] { GV.stSep };
        string[] strArray = processParam.Split(separator, StringSplitOptions.None);

        string asset = strArray[0];
        string equipmentType = strArray[1];

        grid.Loader.SelectFields =
            "a.asset AS CSite, " +
            "b.asset AS CAsset," +
            "Asset.assetName AS CAssetName";

        grid.Loader.AddTable("V_AssetParentAssetCL", "a");
        grid.Loader.AddTable("V_AssetParentAssetCL", "b");
        grid.Loader.AddTable("Asset", "Asset");

        grid.Loader.AddWhereTable("a.asset", "b.parentAsset");
        grid.Loader.AddWhereTable("Asset.asset", "b.asset");

        grid.Loader.WhereConditions.Add("a.parentAsset", ConditionOP.Equal, asset);
        grid.Loader.WhereConditions.Add("b.parentCompanyLevel", ConditionOP.Equal, 8);
        //grid.Loader.WhereConditions.Add("b.companyLevel", ConditionOP.GreaterThan, 8);
        grid.Loader.WhereConditions.Add("Asset.equipmentType", ConditionOP.Equal, equipmentType);
        grid.Loader.WhereConditions.Add("Asset.recordState", ConditionOP.Equal, "OP");
        grid.Loader.OrderFields = "a.parentAsset, a.parentCompanyLevel, a.asset, a.companyLevel, b.asset, b.companyLevel";
    }

 protected override void UpdateGridDataSource(IGrid grid, DataTable dtData, string processParam)
    {
        string[] separator = new string[] { GV.stSep };
        string[] strArray = processParam.Split(separator, StringSplitOptions.None);

        string asset = strArray[0];
        string equipmentType = strArray[1];

        int countTechChar = Convert.ToInt32(this.ProcessManager.SqlE.SelectCommandOneValue("EquipmentTypeTechChar", "ISNULL(COUNT(EquipmentTypeTechChar.techCharacteristic), 0 )", "equipmentType", equipmentType));

        if (countTechChar > 0)
        {

            for (int x = 1; x <= countTechChar; x++)
                dtData.Columns.Add("Column" + x, typeof(string));

            foreach (DataRow row in dtData.Rows)
            {
                var z = 0;
                DataTable dt = LoadSelectWorkOrder(row["CAsset"].ToString());

                for (int y = 1; y <= countTechChar; y++)
                {
                    row["Column" + y] = dt.Rows[z]["value"].ToString();
                    z++;
                }
            }
        }
    }

Someone can help me?

  • One of those lines from your DataTable returns the field with the dates?

  • @Alberttsantos Sim

  • @Alberttsantos edited the source, if possible from a check

  • Your question has been marked as duplicate, which is why I can’t answer you. You can try to pick up the line where your date is filled and simply put .ToString(dd:MM:yyy) to format it.

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.