Solved

datetime set

Posted on 2013-11-21
3
251 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

On Demand Webinar: Networking for the Cloud Era

Ready to improve network connectivity? Watch this webinar to learn how SD-WANs and a one-click instant connect tool can boost provisions, deployment, and management of your cloud connection.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

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.
This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
This is a high-level webinar that covers the history of enterprise open source database use. It addresses both the advantages companies see in using open source database technologies, as well as the fears and reservations they might have. In this…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…

729 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