Click here to Skip to main content
15,888,286 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi all

In my application i have to generate a sales report.

In that the form will have below 2 things

Start time - ComboBox(e.g 10:00 am)
time span - ComboBox(e.g 20)

Start time is like for a particular store there day starts at 10:00 am
and span is they calculate there day as 20 hours starting from 10:00 am.

so i have to generate the sales report starting from 10:00 am + 20 hour

e.g if the user select date as 18-01-2014
Start time 10:00 am
Time span 20 hours

so it should give the report from 18-01-2014 10:00 am to 19-01-2014 6:00am

Please need some ideas how to approach..

Thank you
Posted

1 solution

Try like this..

C#
string date = "18-01-2014"; // get from combobox
            string time = "10:00 am"; // get from combobox
            string timespan = "20"; // get from combobox

           double span = Convert.ToDouble(timespan);
           string input = string.Format("{0} {1}",date,time);
          DateTime startTime =  DateTime.ParseExact(input, "dd-MM-yyyy hh:mm tt", null);
          DateTime endTime = startTime.AddHours(span);

          Console.WriteLine(startTime);
          Console.WriteLine(endTime);
 
Share this answer
 
Comments
Mitchell J. 17-Jan-14 23:36pm    
Nice solution :-)
Karthik_Mahalingam 17-Jan-14 23:38pm    
thanks craig :)
[no name] 17-Jan-14 23:59pm    
Thanks KARTHIK..i will check and reply back to you..
Karthik_Mahalingam 18-Jan-14 0:05am    
sure SN :)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900