Instance 365 (3) --------- DateDiff function, get the age by birthday

Source: Internet
Author: User
Tags date1

I:

Ii. Code
Using System; using System. collections. generic; using System. componentModel; using System. data; using System. drawing; using System. linq; using System. text; using System. windows. forms; using Microsoft. visualBasic; namespace GetAge {public partial class Frm_Main: Form {public Frm_Main () {InitializeComponent ();} private void btn_GetAge_Click (object sender, EventArgs e) {long P_BirthDay = DateAndTime. dateD Iff (DateInterval. Year, // age dtpicker_BirthDay.Value, DateTime. Now, FirstDayOfWeek. Sunday, FirstWeekOfYear. Jan1);/* parameter description * Interval is required. The DateInterval enumerated value or String expression, indicating the time interval of the Unit for the difference between Date1 and Date2. Date1 is required. Date. The first date/time value to be used in the calculation. Date2 is required. Date. The second date/time value to be used in the calculation. Optional. Value selected from the FirstDayOfWeek enumeration, used to specify the first day of a week. If not specified, use FirstDayOfWeek. Sunday. WeekOfYear is optional. Value selected from the FirstWeekOfYear enumeration. This enumeration is used to specify the first week of the year. If not specified, use FirstWeekOfYear. Jan1. */MessageBox. Show (string. Format ("Age: {0} years old. ", // Output age information P_BirthDay.ToString ()," prompt! ");}}}

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.