Skip to main content

eBA DateTime Object Examples

DateTime Taking Different Days

You cannot access the fields selected as textbox type date in the form of text. The textbox object type selected as the date changes to eBADatetimeBox. Subtracting two dates returns the result as a TimeSpan object. For this, you need to examine the C# timespan object. As an example, when you call the TotalDays variable of the timeSpan object, it returns double as the day difference between two dates.

It is assumed that the EbaDateTime objects are Text1 and Text2.
if (Text1.IsValid & Text2.IsValid)
{
SumSure.Text = (Text2.Value - Text1.Value). TotalDays.ToString();
}

Detailed example of taking the day difference between two dates

   DateTime dtStart = DateTime.Parse(txt_GirisTarih.Text);

DateTime dtEnd = DateTime.Parse(txt_CikisTarih.Text);

TimeSpan time = new TimeSpan();

time = dtEnd - dtStart;

int dayDiff = Convert.ToInt32(time. TotalDays) ;

DateTime Year Calculator

DateTime myDate = DateTime.ParseExact(Text1.Text, "d.M.yyyy HH:mm:ss", CultureInfo.InvariantCulture);       d.M.yyyy HH:mm:ss format of the string we translated      
TimeSpan ts = Text2.Value - myDate;
ShowMessageBox((ts. TotalDays / 365.25). ToString());

DateTime Convert Difference Between Two Dates in Seconds to Milliseconds

Based on this example, TimeSpan can be used as a structure such as Day, Hour, Hour to minute, or vice versa.

Metin6-Metin8 eBADatetimeBox

TimeSpan ts = Metin6.Value.Subtract(Metin8.Value); We can access it from within the TimeSpan object, so we take the difference of the two texts and get the ts value.
Text7.Text =ts. TotalMilliseconds.ToString(); Then we convert TS to milliseconds and print it to text.

eBADateTime Find the Day of the Selected Date

public void OnModalReturn(object sender, eBAModalEventArgs e)

{

if(sender == Text6)

{

int day = Convert.ToInt32(Text6.Value.DayOfWeek);

Switch (day)

{

Case 1:

Text12.Text = "Monday";

Break;

Case 2:

Text12.Text ="Tuesday";

Break;

Case 3:

Text12.Text ="Wednesday";

Break;

Case 4:

Text12.Text ="Thursday";

Break;

Case 5:

Text12.Text ="Friday";

Break;

Case 6:

Text12.Text ="Saturday";

Break;

Case 7:

Text12.Text = "Sunday";

Break;

}

}

}