yesterday's time

This is a discussion on yesterday's time within the C# Programming forums, part of the General Programming Boards category; Hello everyone, I want to get the same time in yesterday, is there any bug in my below code? My ...

  1. #1
    Registered User
    Join Date
    May 2006
    Posts
    1,579

    yesterday's time

    Hello everyone,


    I want to get the same time in yesterday, is there any bug in my below code?

    My concern is code, _CurrentDate.Now.Day - 1, if current date is 1, 1 minus 1 is zero, not a valid date?

    Code:
            DateTime _CurrentDate = DateTime.Now;
            DateTime _LastDate = new DateTime(_CurrentDate.Now.Year, _CurrentDate.Now.Month, _CurrentDate.Now.Day - 1, _CurrentDate.Now.Hour, _CurrentDate.Now.Second);

    thanks in advance,
    George

  2. #2
    the hat of redundancy hat nvoigt's Avatar
    Join Date
    Aug 2001
    Location
    Hannover, Germany
    Posts
    3,139
    You want to subtract one day from your date ? Well, how about reading the help file, which will tell you how to do so one the very first page ? I will not be your copy&paste fool. Go read up on it for yourself.
    hth
    -nv

    She was so Blonde, she spent 20 minutes looking at the orange juice can because it said "Concentrate."

    When in doubt, read the FAQ.
    Then ask a smart question.

  3. #3
    and the Hat of Clumsiness GanglyLamb's Avatar
    Join Date
    Oct 2002
    Location
    between photons and phonons
    Posts
    1,109
    And really you might consider stopping the cross posts...

    Search for every thread you started here and you will find like 3 different places where you asked the question...

    For this thread you can get answers at codeguru (www.codeguru.com/forum/showthread.php?threadid=454601) and at http://forums.devarticles.com/net-development-43/

    If you really find it that hard to come up with solutions to problems like this then well i can only conclude you are not that good of a programmer... If you don't know search the help pages on msdn, if that still doesnt help you forward you can still think about things a bit and find out yourself...

    Sorry if this sounds offending but thats just my opinion.

    And oh yeah before i forget those are not the only places you cross post at: csharpfriends, boardreader.com, forums.msdn.microsoft.com and probably many more all seem favorite places for you to spam your questions around.
    Last edited by GanglyLamb; 06-06-2008 at 04:03 AM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 26
    Last Post: 07-05-2010, 11:43 AM
  2. Replies: 11
    Last Post: 03-29-2009, 01:27 PM
  3. calculating user time and time elapsed
    By Neildadon in forum C++ Programming
    Replies: 0
    Last Post: 02-10-2003, 06:00 PM
  4. Is this really true or it's just science fiction?
    By Nutshell in forum A Brief History of Cprogramming.com
    Replies: 145
    Last Post: 04-09-2002, 07:17 PM
  5. time class
    By Unregistered in forum C++ Programming
    Replies: 1
    Last Post: 12-11-2001, 10:12 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21