Results 1 to 4 of 4

Thread: Yesterday's Date? - RESOLVED!

Threaded View

  1. #1

    Thread Starter
    Hyperactive Member rockies1's Avatar
    Join Date
    Jul 1999
    Location
    Stuck at work
    Posts
    375

    Yesterday's Date? - RESOLVED!

    I have some code that works to calculate yesterday's date and it has worked great, until today.

    Anyone have something that works correctly?

    Here's mine:
    Code:
    		public static String CalcYestDate()
    		{
    			//Set up date to run for
    			java.util.Calendar  gc;
    			java.util.Date  curDate;
    			String  strCurDate = null;
    			String fileDate = new String();
    
    			gc = GregorianCalendar.getInstance ( ); // Gets the current Calendar instance
    			gc.roll(gc.DATE,false);
    
    			curDate = gc.getTime ( ); // Gets the Date time part of gc
    			SimpleDateFormat sdf2 = new SimpleDateFormat ( "yyyyMMdd" ); //sets up the correct format for the date
    			fileDate = sdf2.format ( curDate );  //Changes the date into the correct date format
    
    			return(fileDate);
    	}//End CalcYestDate
    When I ran it today it returned 20030731 instead of 20030630.

    Thanks!

    Morgan
    Last edited by rockies1; Jul 1st, 2003 at 03:20 PM.
    Morgan
    [email protected] - Home
    [email protected] - Work
    Using VB6 SP6 but trying to learn VB2005EE

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width