how to deduct time/date from current datetime

You will need to test this and it may need amending slightly but try working on this…

    TimeSpan eTs = new TimeSpan(23, 30, 00);
    double inMins;

    if (DateTime.Now.TimeOfDay < eTs)
    {
        DateTime dTarget = DateTime.Now.AddDays(-1).Date + eTs;
        TimeSpan ts = DateTime.Now.Subtract(dTarget);
        inMins = ts.TotalMinutes;
    }
    else
    {
        DateTime dTarget = DateTime.Now.Date + eTs;
        TimeSpan ts = DateTime.Now.Subtract(dTarget);
        inMins = ts.TotalMinutes;
    }

Browse More Popular Posts

Leave a Comment