Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

datetime set

Posted on 2013-11-21
3
Medium Priority
?
256 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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
Is your data getting by on basic protection measures? In today’s climate of debilitating malware and ransomware—like WannaCry—that may not be enough. You need to establish more than basics, like a recovery plan that protects both data and endpoints.…

618 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