none
Date and time RRS feed

  • Question

  • I have a C# application which is a GUI, a form interacting with an SQL Server Database. This particular table needs to store future appointments. It is convenient to type the columns there date and time separately. I have trouble figuring out how I can do it on the Form input. DateTimePicker does not allow me to manipulate time, only date. ToolBox for SSMS does not have a TimePicker, actually it does exist in one of the subsections of controls but it is dimmed.

    Any suggestions how I can do it?

    Thanks, - MyCatAlex

    Friday, August 10, 2018 2:54 PM

Answers

  • In order to make a time picker, try using a DateTimePicker, setting Format to “Time” and ShowUpDown to “True”.

    To edit date and time in one control, set Format to “Custom”, CustomFormat to something like “dd'.'MM'.'yyyy HH':'mm” depending on needs, and ShowUpDown to “False”.

     




    • Edited by Viorel_MVP Friday, August 10, 2018 3:47 PM
    • Marked as answer by MyCatAlex Friday, August 10, 2018 3:59 PM
    Friday, August 10, 2018 3:46 PM

All replies

  • In order to make a time picker, try using a DateTimePicker, setting Format to “Time” and ShowUpDown to “True”.

    To edit date and time in one control, set Format to “Custom”, CustomFormat to something like “dd'.'MM'.'yyyy HH':'mm” depending on needs, and ShowUpDown to “False”.

     




    • Edited by Viorel_MVP Friday, August 10, 2018 3:47 PM
    • Marked as answer by MyCatAlex Friday, August 10, 2018 3:59 PM
    Friday, August 10, 2018 3:46 PM
  • Sure it works. Thanks, - MyCatAlex
    Friday, August 10, 2018 4:00 PM
  • One more thing. How should I type date and time in C# code to save them in SQL Table?

    Thanks. - MyCatAlex

    Friday, August 10, 2018 4:06 PM
  • I figured out everything rest. Thank you, - MyCatAlex
    Friday, August 10, 2018 5:24 PM