Hi @Padmanabhan, Venkatesh, welcome to Microsoft Q&A.
You only need to understand the format principle of ToString("yyyy-MM-dd HH:mm:ss"));
. So, you could do as follows.
using System;
namespace ConsoleApp3
{
internal class Program
{
static void Main(string[] args)
{
//just for testing
int date = 1211210;
int time = 73001;
int year = date / 10000 + 1900; // (e.g. 2021)
int month = date % 10000 / 100; // (e.g. 12)
int day = date % 100; // (e.g. 10)
int hour = time / 10000; // (e.g. 7)
int minute = time % 10000 / 100; // (e.g. 30)
int second = time % 100; // (e.g. 1)
DateTime as400DT = new DateTime(year, month, day, hour, minute, second);
DateTime currentDT = DateTime.Now;
// Calculate the time difference in minutes
TimeSpan timeDifference = currentDT - as400DT;
int timeDifferenceMinutes = (int)timeDifference.TotalMinutes;
// Display the results
Console.WriteLine("AS400 Date and Time: " + as400DT.ToString("yyyy-MM-dd HH:mm:ss"));
Console.WriteLine("Current Date and Time: " + currentDT.ToString("yyyy-MM-dd HH:mm:ss"));
Console.WriteLine("Time Difference (Minutes): " + timeDifferenceMinutes);
Console.ReadLine();
}
}
}
Best Regards,
Jiale
If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.