Quantcast
Channel: Forums - Python
Viewing all articles
Browse latest Browse all 2485

Get YYYYMMDD String from Date

$
0
0
I have a script where the user enters a StartDate and EndDate (via arcpy.GetParameterAsText dialog boxes).

I want to return strings of those dates in a "YYYYMMDD" format. In another script, I used a snippet to loop through the dates and return a string (CurrentDate) in YYYYMMDD format, but I really don't understand how that function works.

Thanks for any help,

Jon Mulder

Code:

import arcpy

from datetime import date
from dateutil.rrule import rrule, DAILY
import time

StartDate = arcpy.GetParameterAsText(0)
EndDate = arcpy.GetParameterAsText(0)
print StartDate
strStartDate = "YYYYMMDD"          #How do I get this format?


for dt in rrule(DAILY, dtstart=DateStart, until=DateEnd):
    CurrentDate = dt.strftime("%Y%m%d")

print "Done."


Viewing all articles
Browse latest Browse all 2485

Trending Articles