Aug-01-2018, 10:28 PM
Hi there
From my understanding, you can use the
From my understanding, you can use the
import datetimemodule to subtract two different datetimes. But when I try to execute this, my code throws the error: TypeError: unsupported operand type(s) for -: 'datetime.datetime' and 'tuple'. Below is my code. Any reason why this isn't working? Everything is formatted the same.
flightDate = datetime.datetime(flight_year, flight_month, flight_day, flight_hour, 0, 0) GFSDate = int(time.strftime("%Y%m%d")) GFSDate = str(GFSDate) GFSDateTime = datetime.datetime(int(GFSDate[:4]),int(GFSDate[4:6]),int(GFSDate[6:]),GFSTime, 0, 0) def findGFSTimeIndex(predictionDateTime, GFSDateTime): diff = predictionDateTime - GFSDateTime return int(np.round((diff.total_seconds()/3600)/3))But I am actually using it with these parameters later on, which is where it is getting snagged:
timeIndex = GFSReader.findGFSTimeIndex(flightDate, gfsDate)Which then gives the error:
TypeError: unsupported operand type(s) for -: 'datetime.datetime' and 'tuple'I'm confused where this is coming from because everywhere I have looked, it says you can subtract datetime.datetime values. Any suggestions? Thanks!