date format: YyyyMMdd HH:mm:ss (note the letter case of this string is strict)
yyyy: Represents the year mm: represents the month DD: Represents the day HH: Represents the hour (24-hour system) mm: Represents the minute SS: represents the second DateTime.Now.ToShortTimeString () DateTime DT=Datetime.now;dt. ToString ();//2005-11-5 13:21:25Dt. Tofiletime (). ToString ();//127756416859912816Dt. TOFILETIMEUTC (). ToString ();//127756704859912816Dt. ToLocalTime (). ToString ();//2005-11-5 21:21:25Dt. Tolongdatestring (). ToString ();//November 5, 2005Dt. Tolongtimestring (). ToString ();//13:21:25Dt. ToOADate (). ToString ();//38661.5565508218Dt. ToShortDateString (). ToString ();//2005-11-5Dt. Toshorttimestring (). ToString ();//13:21Dt. ToUniversalTime (). ToString ();//2005-11-5 5:21:25Dt. Year.tostring ();//2005Dt. Date.tostring ();//2005-11-5 0:00:00Dt. Dayofweek.tostring ();//SaturdayDt. Dayofyear.tostring ();//309Dt. Hour.tostring ();// -Dt.Millisecond.ToString ();//441Dt. Minute.tostring ();// -Dt. Month.tostring ();// OneDt. Second.tostring ();// -Dt. Ticks.tostring ();//632667942284412864Dt. Timeofday.tostring ();//13:30:28.4412864Dt. ToString ();//2005-11-5 13:47:04Dt. AddYears (1). ToString ();//2006-11-5 13:47:04Dt. AddDays (1.1). ToString ();//2005-11-6 16:11:04Dt. AddHours (1.1). ToString ();//2005-11-5 14:53:04Dt. Addmilliseconds (1.1). ToString ();//2005-11-5 13:47:04Dt. AddMonths (1). ToString ();//2005-12-5 13:47:04Dt. AddSeconds (1.1). ToString ();//2005-11-5 13:47:05Dt. AddMinutes (1.1). ToString ();//2005-11-5 13:48:10Dt. Addticks ( +). ToString ();//2005-11-5 13:47:04Dt.compareto (DT). ToString ();//0Dt. ADD (?). ToString ();//question mark is a time periodDt. Equals ("2005-11-6 16:11:04"). ToString ();//FalseDt. Equals (DT). ToString ();//TrueDt. GetHashCode (). ToString ();//1474088234Dt. GetType (). ToString ();//System.DateTimeDt. GetTypeCode (). ToString ();//DateTimedt. Getdatetimeformats ('s')[0]. ToString ();//2005-11-05t14:06:25Dt. Getdatetimeformats ('T')[0]. ToString ();//14:06Dt. Getdatetimeformats ('y')[0]. ToString ();//November 2005Dt. Getdatetimeformats ('D')[0]. ToString ();//November 5, 2005Dt. Getdatetimeformats ('D')[1]. ToString ();//2005Dt. Getdatetimeformats ('D')[2]. ToString ();//Week 62,005Dt. Getdatetimeformats ('D')[3]. ToString ();//Saturday November 5, 2005Dt. Getdatetimeformats ('M')[0]. ToString ();//November 5Dt. Getdatetimeformats ('F')[0]. ToString ();//November 5, 2005 14:06Dt. Getdatetimeformats ('g')[0]. ToString ();//2005-11-5 14:06Dt. Getdatetimeformats ('R')[0]. ToString ();//Sat, Nov 2005 14:06:25 GMTstring. Format ("{0:D}", DT);//2005-11-5string. Format ("{0}", DT);//November 5, 2005string. Format ("{0:f}", DT);//November 5, 2005 14:23string. Format ("{0:f}", DT);//November 5, 2005 14:23:23string. Format ("{0:g}", DT);//2005-11-5 14:23string. Format ("{0:g}", DT);//2005-11-5 14:23:23string. Format ("{0:m}", DT);//November 5string. Format ("{0:r}", DT);//Sat, Nov 2005 14:23:23 GMTstring. Format ("{0:s}", DT);//2005-11-05t14:23:23string. Format ("{0:t}", DT);//14:23string. Format ("{0:t}", DT);//14:23:23string. Format ("{0:u}", DT);//2005-11-05 14:23:23zstring. Format ("{0:u}", DT);//November 5, 2005 6:23:23string. Format ("{0:y}", DT);//November 2005string. Format ("{0}", DT);//2005-11-5 14:23:23string. Format ("{0:YYYYMMDDHHMMSSFFFF}", DT); Calculates the difference in the number of days between 2 dates-----------------------------------------------DateTime dt1= Convert.datetime ("2007-8-1");D atetime DT2= Convert.datetime ("2007-8-15"); TimeSpan span=DT2. Subtract (DT1);intDaydiff = span. Days +1; Calculates the number of days of a month in a year-----------------------------------------------intDays = Datetime.daysinmonth ( -,8);d ays= toadd one day to date, one day less-----------------------------------------------DateTime DT=Datetime.now;dt. AddDays (1);//Add one dayDt. AddDays (-1);//Reduce the dayother years method similar ... Convert Date function in Oracle SQL-----------------------------------------------To_date ("2007-6-6",'yyyy-mm-dd ");To_date ("2007/6/6",'yyyy/mm/dd ");
Original address: http://www.cnblogs.com/qq450867541/p/6112862.html
C # to convert datetime type dates to month date or other Format method summary