?
Solved

datetime set

Posted on 2013-11-21
3
Medium Priority
?
253 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 668 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 668 total points
ID: 39665746
((System.DateTime)CalenderDate.SelectedDate).Add ( new TimeSpan ( DateTime.Now.TimeOfDay.Ticks ) )
0
 
LVL 7

Assisted Solution

by:keustermans
keustermans earned 664 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

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
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.
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
Suggested Courses

770 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