animedragonfighter animedragon​fighter

Niner since 2012


  • Working with DateTime - 13

    I had fun working with DateTime, I even created a console app that tells my grandfather happy birthday, how many days to wait until it tells him happy birthday, and even when his birthday pass, it will tell him to delete the file. This was a whole lot more fun and better then making a card or sending an eCard.

    Here is the code I used.


    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    namespace ConsoleApplication1
        class Program
            static void Main(string[] args)
                /* If you want to use this file to tell someone happy birthday,
                 * all you must do is change the "OPEN THIS...", the birthDay value, 
                 * and the names, telling who's birthday it is and who it is from. 
                // The Information at the top of the Console
                Console.WriteLine("O P E N   T H I S   P R O G R A M   2 0 1 2");
                //The Variables and Data Types
                DateTime rightNow = DateTime.Now.Date;
                DateTime birthDay = DateTime.Parse("01/28/2012");
                TimeSpan daysLeft = birthDay.Subtract(DateTime.Now);
                //If Today is his birthday
                if (rightNow == birthDay)
                    Console.WriteLine("Happy Birthday Papa!\n \n From: name");
                    // If his bithday has already passed
                else if (rightNow > birthDay)
                    Console.WriteLine("Sorry, but this program is valid for this year only.  This program is no longer of  any use, you may delete it.");
                    //If his birthday hasn't quite made it here yet
                    Console.WriteLine("Sorry, but you must wait " + daysLeft.Days + " days, then open this file. \n");
                    Console.WriteLine("It is currently: " + DateTime.Now);