0

I have created a python script which do birthday wish to a person automatically when birthdate is arrive. I added this script on window start up but it run every time when i start my pc and do birthday wish to person also. I want to run that script only once a day. What should i do?

Smit Parmar
  • 178
  • 2
  • 11

2 Answers2

1

Try this at the start of the file:

import datetime

actualday = datetime.datetime.today().day  # get the actual day 
actualmonth = datetime.datetime.today().month  # get the actual month 

bday = 1  # day of birthday
bmonth = 1  # month of birthday

if actualday == bday and actualmonth == bmonth :
    # code

it should finish the process if the dates aren't equal

Alessio7
  • 26
  • 1
0

You can run this program when the system boot How to start a python file while Windows starts?

And after that, you need check the time of when the system started like:

import datetime
dayToday = datetime.datetime.today().day
monthToday = datetime.datetime.today().month

birthdayDay = 1
birthdayMonth = 10

if dayToday == birthdayDay and monthToday == birthdayMonth:
      print "HPBD"
AJackTi
  • 63
  • 2
  • 7