Friday, October 14, 2016

Convert Long to date C#

Hi All,

Code for getting Date from string

string loopListValue = "19900131000000";

DateTime GetDate= Number2Date(Convert.ToInt64(loopListValue));

private DateTime Number2Date(long number)
        {
            string strNum = number.ToString();
            int day, month, year;
            DateTime validDate = DateTime.Now;
            if (strNum.Length == 7)
            {
                strNum = "0" + strNum;
            }

            year = Convert.ToInt32(strNum.Substring(0, 4));
            month = Convert.ToInt32(strNum.Substring(4, 2));
            day = Convert.ToInt32(strNum.Substring(6, 2));
            validDate = new DateTime(year, month, day);
            return validDate;
        }

No comments:

Post a Comment

Day 11 - Customizing Option Sets Dropdown Fields with JavaScript

  In this Blog, we will see how to Customizing Option Sets Dropdown Fields with JavaScript label1 = formContext.getAttribute( "bosch_op...