Solved

datetime set

Posted on 2013-11-21
3
246 Views
Last Modified: 2013-11-25
This code below selects the date by the user and as per selection returns the selected date but the
time is reset to 12:00AM.For example if user select o6/11 the return is "
06-11-2013 00:00" but i want the time to reflect the current time from the server...

private void CalenderDate_SelectedDatesChanged(object sender, SelectionChangedEventArgs e)
        {
            List<string> strdet = new List<string>();
            strdet.Add("essaetechnologyspvtlimited");
            strdet.Add("dev");
            strdet.Add("essaecrm@live.in");
            strdet.Add("Essae@123");
            strdet.Add("crm5");
            GridViewData gdv = new GridViewData();
            gdv.dtx(org.getOrders((System.DateTime)CalenderDate.SelectedDate), strdet);
            gdv.ShowDialog();
        }
0
Comment
Question by:Moizsaif123
3 Comments
 
LVL 19

Accepted Solution

by:
Albert Van Halen earned 167 total points
ID: 39665688
I would create an extension method for this.
Look at the example below
public static DateTime WithCurrentTime(this DateTime input)
{
	DateTime now = DateTime.Now;

	return new DateTime(input.Year, input.Month, input.Day, now.Hour, now.Minute, now.Second);
}

Open in new window

Usage :
((System.DateTime)CalenderDate.SelectedDate).WithCurrentTime()

Open in new window

0
 
LVL 40

Assisted Solution

by:Jacques Bourgeois (James Burger)
Jacques Bourgeois (James Burger) earned 167 total points
ID: 39665746
((System.DateTime)CalenderDate.SelectedDate).Add ( new TimeSpan ( DateTime.Now.TimeOfDay.Ticks ) )
0
 
LVL 7

Assisted Solution

by:keustermans
keustermans earned 166 total points
ID: 39668634
Hi There,

Use a DateTimePicker control

and do the following:

private void dateTimePicker1_ValueChanged(object sender, EventArgs e)
{
     string a = "a";

     System.DateTime dt = ((DateTimePicker)sender).Value;
}
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

746 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now