I'm attempting to retrieve the year from the following date format: 1/1/1988 I've tried the following but it does not work str(1/1/1988)[4:] and I've also tried str(1//1//1988)[4:]
This sort of question is better answered in StackOverflow but the answer is straight-forward enough so I'll give you a hint here.
Your date is not a date as far as Python is concerned but a division sum - which is the main reason why it doesn't work. Your code also won't give you the last four digits. You need '[-4:]' (yours gives everything except the first four characters of the string). You need to cast your date as a date using the datetime module. Then to convert a properly cast date as a string in the format you have in your original post you call