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

How to Run Microsoft Flow for Every one Month

Introduction: In this Blog we will see how to Run Microsoft Flow for Every one Month. Implementation Steps:   1. Navigate to  https://make.p...