Fix calculation logic for date time