Python Forum
Logic to convert an integer to YEAR / MONTH
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Logic to convert an integer to YEAR / MONTH
#1
Lógica para converter um número inteiro para ANO/MÊS

Pessoal, Boa tarde.
Preciso de uma ajuda. Minha dúvida nem é na sintaxe em si, mas em lógica mesmo. Sozinho não to conseguindo resolver.
Preciso criar Arquivos com nome ("DC" + anoAtual + Mes). ex: DC201610, somar 1 ano se passar do mês 12 e ir incrementando o mês até 12
O usuário entra com 2 entradas.
  1. Número de meses para gerar

  2. Mes de inicio de 1..12
Eu já to gerando os arquivos, e criando os nomes. Mas só funciona se o usuario de o mês de inicio o mês 01 = Janeiro. porque ele vai até 12 e volta para 01.
O problema está se o usuário começa no mês 10 e precisa criar 5 meses(Arquivos) por exemplo.
Como deveria ficar: DC201610       Como ele está criando: DC201610
                                DC201611                                            DC201611
                                DC201612                                            DC201612
                                DC201701                                            DC201613
                                DC201702                                            DC201614

Alguém pode me ajudar?  :wall:


Translation
Staff, Good afternoon.
I need help. My question is not in the syntax itself, but even in logic. Alone not getting to solve.
I need to create files with the name ("DC" + anoAtual + Mes). eg DC201610, add one year to spend the month 12 and go up to 12 incrementing the month
The user enters 2 entries.

  1. Number of months to generate
  2. Start Month 1..12

I have to generate the files, and creating names. But it only works if the User of the beginning of the month month = January 01. because it goes to 12 and back to 01.
The problem is if the user begins the month 10 and need to create five months (Files) for example.

As it should be:
Output:
DC201610 DC201611 DC201612 DC201701 DC201702
as it is creating:
Output:
DC201610 DC201611 DC201612 DC201613 DC201614
Can someone help me?  :wall:
Reply


Messages In This Thread
Logic to convert an integer to YEAR / MONTH - by hugobaur - Oct-13-2016, 06:58 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  get list of dates in past month, current and upcoming month jacksfrustration 4 595 Feb-03-2024, 06:37 PM
Last Post: deanhystad
  Trying to get year not the entire year & time mbrown009 2 904 Jan-09-2023, 01:46 PM
Last Post: snippsat
  Python Resampling: How do I obtain the value of the last week of the month? JaneTan 2 1,035 Dec-12-2022, 12:49 AM
Last Post: JaneTan
  How to convert 4 bytes to an integer ? GiggsB 11 6,949 Jan-20-2022, 03:37 AM
Last Post: GiggsB
  Appropriate data-structure / design for business-day relations (week/month-wise) sx999 2 2,824 Apr-23-2021, 08:09 AM
Last Post: sx999
  Search Results Web results Printing the number of days in a given month and year afefDXCTN 1 2,256 Aug-21-2020, 12:20 PM
Last Post: DeaD_EyE
  Help with implementation of the logic to convert roman numeral to integer jagasrik 2 2,334 Aug-14-2020, 07:31 PM
Last Post: deanhystad
  Learning Python in a month MuhammadNauman 1 1,785 Jul-17-2019, 11:53 AM
Last Post: metulburr
  How to get all the data for the current month in ms Access using python? aeo03 1 2,326 Nov-07-2018, 08:21 PM
Last Post: micseydel
Question [Help] Convert integer to Roman numerals? {Screenshot attached} vanicci 10 9,222 Aug-06-2018, 05:19 PM
Last Post: vanicci

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020