increment a date by one day for 15 days.











up vote
-2
down vote

favorite












Why don't I get any results from this code. Can you please help me.



from datetime import datetime, timedelta
myStr = '20170817'
dateObj = datetime.strptime(myStr, '%Y%m%d')
timeStep = timedelta(days=1)

def Days15(myStr):
dateList = [dateObj + timeStep*i for i in range(15)]
return dateList









share|improve this question







New contributor




Nathan is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.




















  • Do you get an error message? Or do you get an output at all? What do you expect or hope to happen?
    – Alex_P
    Nov 10 at 19:14








  • 2




    Your code works, but you're not actually printing anything out. Throw a print Days15(myStr) at the end of your code and you'll see 15 date objects
    – ahota
    Nov 10 at 19:16










  • When saying you don't get "any results", it helps to give an example of input and expected output pair. You created a function called Days15, which you are not calling. Please use lower case name for functions. Also, it looks to me you don't need a function in this example.
    – Mircea
    Nov 10 at 19:18










  • Thank you. I've tried putting in the print Days15(myStr) in different sections but it's giving me a syntax error. Where do I put the pring command in?
    – Nathan
    Nov 10 at 19:24










  • also, here is the results I'm trying to get: [datetime.datetime(2017, 8, 17, 0, 0), datetime.datetime(2017, 8, 18, 0, 0), datetime.datetime(2017, 8, 19, 0, 0), datetime.datetime(2017, 8, 20, 0, 0), datetime.datetime(2017, 8, 21, 0, 0), datetime.datetime(2017, 8, 22, 0, 0), datetime.datetime(2017, 8, 23, 0, 0), datetime.datetime(2017, 8, 24, 0, 0), datetime.datetime(2017, 8, 25, 0, 0), datetime.datetime(2017, 8, 26, 0, 0), datetime.datetime(2017, 8, 27, 0, 0), datetime.datetime(2017, 8, 28, 0, 0), datetime.datetime(2017, 8, 29, 0, 0), datetime.datetime(2017, 8, 30, 0, 0), datetime.datetime(2017
    – Nathan
    Nov 10 at 19:25















up vote
-2
down vote

favorite












Why don't I get any results from this code. Can you please help me.



from datetime import datetime, timedelta
myStr = '20170817'
dateObj = datetime.strptime(myStr, '%Y%m%d')
timeStep = timedelta(days=1)

def Days15(myStr):
dateList = [dateObj + timeStep*i for i in range(15)]
return dateList









share|improve this question







New contributor




Nathan is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.




















  • Do you get an error message? Or do you get an output at all? What do you expect or hope to happen?
    – Alex_P
    Nov 10 at 19:14








  • 2




    Your code works, but you're not actually printing anything out. Throw a print Days15(myStr) at the end of your code and you'll see 15 date objects
    – ahota
    Nov 10 at 19:16










  • When saying you don't get "any results", it helps to give an example of input and expected output pair. You created a function called Days15, which you are not calling. Please use lower case name for functions. Also, it looks to me you don't need a function in this example.
    – Mircea
    Nov 10 at 19:18










  • Thank you. I've tried putting in the print Days15(myStr) in different sections but it's giving me a syntax error. Where do I put the pring command in?
    – Nathan
    Nov 10 at 19:24










  • also, here is the results I'm trying to get: [datetime.datetime(2017, 8, 17, 0, 0), datetime.datetime(2017, 8, 18, 0, 0), datetime.datetime(2017, 8, 19, 0, 0), datetime.datetime(2017, 8, 20, 0, 0), datetime.datetime(2017, 8, 21, 0, 0), datetime.datetime(2017, 8, 22, 0, 0), datetime.datetime(2017, 8, 23, 0, 0), datetime.datetime(2017, 8, 24, 0, 0), datetime.datetime(2017, 8, 25, 0, 0), datetime.datetime(2017, 8, 26, 0, 0), datetime.datetime(2017, 8, 27, 0, 0), datetime.datetime(2017, 8, 28, 0, 0), datetime.datetime(2017, 8, 29, 0, 0), datetime.datetime(2017, 8, 30, 0, 0), datetime.datetime(2017
    – Nathan
    Nov 10 at 19:25













up vote
-2
down vote

favorite









up vote
-2
down vote

favorite











Why don't I get any results from this code. Can you please help me.



from datetime import datetime, timedelta
myStr = '20170817'
dateObj = datetime.strptime(myStr, '%Y%m%d')
timeStep = timedelta(days=1)

def Days15(myStr):
dateList = [dateObj + timeStep*i for i in range(15)]
return dateList









share|improve this question







New contributor




Nathan is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











Why don't I get any results from this code. Can you please help me.



from datetime import datetime, timedelta
myStr = '20170817'
dateObj = datetime.strptime(myStr, '%Y%m%d')
timeStep = timedelta(days=1)

def Days15(myStr):
dateList = [dateObj + timeStep*i for i in range(15)]
return dateList






python






share|improve this question







New contributor




Nathan is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











share|improve this question







New contributor




Nathan is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









share|improve this question




share|improve this question






New contributor




Nathan is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









asked Nov 10 at 19:13









Nathan

11




11




New contributor




Nathan is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.





New contributor





Nathan is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.






Nathan is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.












  • Do you get an error message? Or do you get an output at all? What do you expect or hope to happen?
    – Alex_P
    Nov 10 at 19:14








  • 2




    Your code works, but you're not actually printing anything out. Throw a print Days15(myStr) at the end of your code and you'll see 15 date objects
    – ahota
    Nov 10 at 19:16










  • When saying you don't get "any results", it helps to give an example of input and expected output pair. You created a function called Days15, which you are not calling. Please use lower case name for functions. Also, it looks to me you don't need a function in this example.
    – Mircea
    Nov 10 at 19:18










  • Thank you. I've tried putting in the print Days15(myStr) in different sections but it's giving me a syntax error. Where do I put the pring command in?
    – Nathan
    Nov 10 at 19:24










  • also, here is the results I'm trying to get: [datetime.datetime(2017, 8, 17, 0, 0), datetime.datetime(2017, 8, 18, 0, 0), datetime.datetime(2017, 8, 19, 0, 0), datetime.datetime(2017, 8, 20, 0, 0), datetime.datetime(2017, 8, 21, 0, 0), datetime.datetime(2017, 8, 22, 0, 0), datetime.datetime(2017, 8, 23, 0, 0), datetime.datetime(2017, 8, 24, 0, 0), datetime.datetime(2017, 8, 25, 0, 0), datetime.datetime(2017, 8, 26, 0, 0), datetime.datetime(2017, 8, 27, 0, 0), datetime.datetime(2017, 8, 28, 0, 0), datetime.datetime(2017, 8, 29, 0, 0), datetime.datetime(2017, 8, 30, 0, 0), datetime.datetime(2017
    – Nathan
    Nov 10 at 19:25


















  • Do you get an error message? Or do you get an output at all? What do you expect or hope to happen?
    – Alex_P
    Nov 10 at 19:14








  • 2




    Your code works, but you're not actually printing anything out. Throw a print Days15(myStr) at the end of your code and you'll see 15 date objects
    – ahota
    Nov 10 at 19:16










  • When saying you don't get "any results", it helps to give an example of input and expected output pair. You created a function called Days15, which you are not calling. Please use lower case name for functions. Also, it looks to me you don't need a function in this example.
    – Mircea
    Nov 10 at 19:18










  • Thank you. I've tried putting in the print Days15(myStr) in different sections but it's giving me a syntax error. Where do I put the pring command in?
    – Nathan
    Nov 10 at 19:24










  • also, here is the results I'm trying to get: [datetime.datetime(2017, 8, 17, 0, 0), datetime.datetime(2017, 8, 18, 0, 0), datetime.datetime(2017, 8, 19, 0, 0), datetime.datetime(2017, 8, 20, 0, 0), datetime.datetime(2017, 8, 21, 0, 0), datetime.datetime(2017, 8, 22, 0, 0), datetime.datetime(2017, 8, 23, 0, 0), datetime.datetime(2017, 8, 24, 0, 0), datetime.datetime(2017, 8, 25, 0, 0), datetime.datetime(2017, 8, 26, 0, 0), datetime.datetime(2017, 8, 27, 0, 0), datetime.datetime(2017, 8, 28, 0, 0), datetime.datetime(2017, 8, 29, 0, 0), datetime.datetime(2017, 8, 30, 0, 0), datetime.datetime(2017
    – Nathan
    Nov 10 at 19:25
















Do you get an error message? Or do you get an output at all? What do you expect or hope to happen?
– Alex_P
Nov 10 at 19:14






Do you get an error message? Or do you get an output at all? What do you expect or hope to happen?
– Alex_P
Nov 10 at 19:14






2




2




Your code works, but you're not actually printing anything out. Throw a print Days15(myStr) at the end of your code and you'll see 15 date objects
– ahota
Nov 10 at 19:16




Your code works, but you're not actually printing anything out. Throw a print Days15(myStr) at the end of your code and you'll see 15 date objects
– ahota
Nov 10 at 19:16












When saying you don't get "any results", it helps to give an example of input and expected output pair. You created a function called Days15, which you are not calling. Please use lower case name for functions. Also, it looks to me you don't need a function in this example.
– Mircea
Nov 10 at 19:18




When saying you don't get "any results", it helps to give an example of input and expected output pair. You created a function called Days15, which you are not calling. Please use lower case name for functions. Also, it looks to me you don't need a function in this example.
– Mircea
Nov 10 at 19:18












Thank you. I've tried putting in the print Days15(myStr) in different sections but it's giving me a syntax error. Where do I put the pring command in?
– Nathan
Nov 10 at 19:24




Thank you. I've tried putting in the print Days15(myStr) in different sections but it's giving me a syntax error. Where do I put the pring command in?
– Nathan
Nov 10 at 19:24












also, here is the results I'm trying to get: [datetime.datetime(2017, 8, 17, 0, 0), datetime.datetime(2017, 8, 18, 0, 0), datetime.datetime(2017, 8, 19, 0, 0), datetime.datetime(2017, 8, 20, 0, 0), datetime.datetime(2017, 8, 21, 0, 0), datetime.datetime(2017, 8, 22, 0, 0), datetime.datetime(2017, 8, 23, 0, 0), datetime.datetime(2017, 8, 24, 0, 0), datetime.datetime(2017, 8, 25, 0, 0), datetime.datetime(2017, 8, 26, 0, 0), datetime.datetime(2017, 8, 27, 0, 0), datetime.datetime(2017, 8, 28, 0, 0), datetime.datetime(2017, 8, 29, 0, 0), datetime.datetime(2017, 8, 30, 0, 0), datetime.datetime(2017
– Nathan
Nov 10 at 19:25




also, here is the results I'm trying to get: [datetime.datetime(2017, 8, 17, 0, 0), datetime.datetime(2017, 8, 18, 0, 0), datetime.datetime(2017, 8, 19, 0, 0), datetime.datetime(2017, 8, 20, 0, 0), datetime.datetime(2017, 8, 21, 0, 0), datetime.datetime(2017, 8, 22, 0, 0), datetime.datetime(2017, 8, 23, 0, 0), datetime.datetime(2017, 8, 24, 0, 0), datetime.datetime(2017, 8, 25, 0, 0), datetime.datetime(2017, 8, 26, 0, 0), datetime.datetime(2017, 8, 27, 0, 0), datetime.datetime(2017, 8, 28, 0, 0), datetime.datetime(2017, 8, 29, 0, 0), datetime.datetime(2017, 8, 30, 0, 0), datetime.datetime(2017
– Nathan
Nov 10 at 19:25

















active

oldest

votes











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});






Nathan is a new contributor. Be nice, and check out our Code of Conduct.










 

draft saved


draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53242510%2fincrement-a-date-by-one-day-for-15-days%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown






























active

oldest

votes













active

oldest

votes









active

oldest

votes






active

oldest

votes








Nathan is a new contributor. Be nice, and check out our Code of Conduct.










 

draft saved


draft discarded


















Nathan is a new contributor. Be nice, and check out our Code of Conduct.













Nathan is a new contributor. Be nice, and check out our Code of Conduct.












Nathan is a new contributor. Be nice, and check out our Code of Conduct.















 


draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53242510%2fincrement-a-date-by-one-day-for-15-days%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Bressuire

Vorschmack

Quarantine