Reputation: 1965
I am really new to Python and I am trying to define two boundary dates start_period_date
and the end_period_date
. The current snippet of code prints this on to a GNU plot graph.
Python Code:
end_period_date = date.strftime( "%A %d %b %Y")
goBack = timedelta(days=8)
start_period_date = end_period_date - goBack
print( "set label 1 \"" + machine_name + "\\nWeekly Utilization Graph " + start_period_date + " till " + end_period_date +"\" at graph 0,1.125 left", file=f )
The output is (top) but I want the output to be the bottom 12 April:
I have tried looking at various examples but I can't seem to see my error. Any suggestions or any other alternatives?
Upvotes: 0
Views: 205
Reputation: 482
Try this way :
import datetime
end_period_date = datetime.date.today()
start_period_date = end_period_date - datetime.timedelta(days=8)
print end_period_date.strftime("%A %d %b %Y")
print start_period_date.strftime("%A %d %b %Y")
Output:
Wednesday 20 Apr 2016
Tuesday 12 Apr 2016
Make sure your end_period_date is date not string. May be will help you.
Upvotes: 1