I need Python to create a file with dd/mm/yyyy formact as its name. I'm new to python any help ?

1643
1
Jump to solution
08-25-2016 02:18 AM
AbhijitAnand
New Contributor

<filename>dd/mm/yyyy should be the formact of the file name

0 Kudos
1 Solution

Accepted Solutions
NeilAyres
MVP Alum

Do something like this :

# name has a "time stamp"
import datetime
Now = datetime.datetime.now()
DateTimeStamp = "_{:%Y%m%d_%H%M}".format(Now)
outFile = "FileBasename" + DateTimeStamp + ".ext"

View solution in original post

1 Reply
NeilAyres
MVP Alum

Do something like this :

# name has a "time stamp"
import datetime
Now = datetime.datetime.now()
DateTimeStamp = "_{:%Y%m%d_%H%M}".format(Now)
outFile = "FileBasename" + DateTimeStamp + ".ext"