15,906,816 members
Sign in
Sign in
Email
Password
Forgot your password?
Sign in with
home
articles
Browse Topics
>
Latest Articles
Top Articles
Posting/Update Guidelines
Article Help Forum
Submit an article or tip
Import GitHub Project
Import your Blog
quick answers
Q&A
Ask a Question
View Unanswered Questions
View All Questions
View C# questions
View C++ questions
View Javascript questions
View Visual Basic questions
View Python questions
discussions
forums
CodeProject.AI Server
All Message Boards...
Application Lifecycle
>
Running a Business
Sales / Marketing
Collaboration / Beta Testing
Work Issues
Design and Architecture
Artificial Intelligence
ASP.NET
JavaScript
Internet of Things
C / C++ / MFC
>
ATL / WTL / STL
Managed C++/CLI
C#
Free Tools
Objective-C and Swift
Database
Hardware & Devices
>
System Admin
Hosting and Servers
Java
Linux Programming
Python
.NET (Core and Framework)
Android
iOS
Mobile
WPF
Visual Basic
Web Development
Site Bugs / Suggestions
Spam and Abuse Watch
features
features
Competitions
News
The Insider Newsletter
The Daily Build Newsletter
Newsletter archive
Surveys
CodeProject Stuff
community
lounge
Who's Who
Most Valuable Professionals
The Lounge
The CodeProject Blog
Where I Am: Member Photos
The Insider News
The Weird & The Wonderful
help
?
What is 'CodeProject'?
General FAQ
Ask a Question
Bugs and Suggestions
Article Help Forum
About Us
Search within:
Articles
Quick Answers
Messages
Comments by Josuha Swannings (Top 2 by date)
Josuha Swannings
24-Apr-23 12:51pm
View
here's the full code if you care and don't have headaches
import java.util.Scanner;
public class days2Dates {
public static void main(String[] args) {
Scanner kb = new Scanner(System.in);
System.out.println("M and D");
int m = kb.nextInt();
int d = kb.nextInt();
System.out.println("M2 and D2");
int m2 = kb.nextInt();
int d2 = kb.nextInt();
kb.close();
int days = 0;
for(int i = m; i<=m2; i++) {
if (i % 2 != 0 || i == 8 || i == 10 || i == 12) {
if (i != 9 && i != 11 && i != m2) {
days = days + (31-d);
}
if (i == 9 && i != m2) {
if (d2<31 && d2>0 && m != 9){
days = days + (d2);
}
if (d2 > 31 && m != 9) {
days = days + 30;
}
if (i == 9 && i != m) {
days = days + (30-d);
}
if (i == m2 && m2 == m) {
days = days + (d2-d);
}
}
if (i == m2 && i != m && i!=9 && i != 11) {
days = days + (31-d);
}
if (i == m2 && m2 == m) {
days = days + (d2-d);
}
if (i == 11 && i != m2) {
if (d2<31 && d2>0 && m != 11){
days = days + d2;
}
if (d2 > 31 && m != 11) {
days = days + 30;
}
if ()
}
}
else if (i % 2 == 0) {
if (i != 2 && i != 8 && i != 10 && i != 12 && i != m) {
if (d < 31 && d > 0){
days = days + d;
}
else {
days = days + 30;
}
}
if (i == 8) {
days = days + d;
}
if (i == 10) {
days = days + d;
}
if (i == 12) {
days = days + d;
}
if (i == m && i != 12){
days = days + d;
}
else if (i == 2){
if (d > 0 && d < 29) {
days = days + d;
}
else {
days = days + 28;
}
}
}
}
System.out.println(days);
//find the number of days from 01/01/2023 till m/d/2023
}
}
Josuha Swannings
24-Apr-23 12:49pm
View
Deleted
I didn't put the full code here because it would be a pain to read.