Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. DateTimePicker

DateTimePicker

Scheduled Pinned Locked Moved C#
questiondatabasehelp
6 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • T Offline
    T Offline
    Trustapple
    wrote on last edited by
    #1

    Hi, I am creating an applicatio that creates databases on the date provided. I have a problem. I am using datetimepicker for selecting the date. I need the application to create the database if teh day of the selected date is Thursday only.Otherwise it should show a message box saying "The selecetd day is not Thursday Do you want to continue or not". How can i do this? public string GetDatabasename() { string namedatabase = dateTimePicker1.Value.ToString("MMdd"); string nameDB = "CustList_PGE_" + namedatabase; MessageBox.Show("The name of the database will be CustList_PGE_" + namedatabase); return nameDB; } The above mentioed code takes the month and day. My datetime picker display is like Thursday February 28,2008 Planning to do it like if in the datetimepicker if its Thursday ,then it will go to a if statement and show the message box. But my problem is how can i read that it is a thursday from datetime picker. Thanking You,

    L J 2 Replies Last reply
    0
    • T Trustapple

      Hi, I am creating an applicatio that creates databases on the date provided. I have a problem. I am using datetimepicker for selecting the date. I need the application to create the database if teh day of the selected date is Thursday only.Otherwise it should show a message box saying "The selecetd day is not Thursday Do you want to continue or not". How can i do this? public string GetDatabasename() { string namedatabase = dateTimePicker1.Value.ToString("MMdd"); string nameDB = "CustList_PGE_" + namedatabase; MessageBox.Show("The name of the database will be CustList_PGE_" + namedatabase); return nameDB; } The above mentioed code takes the month and day. My datetime picker display is like Thursday February 28,2008 Planning to do it like if in the datetimepicker if its Thursday ,then it will go to a if statement and show the message box. But my problem is how can i read that it is a thursday from datetime picker. Thanking You,

      L Offline
      L Offline
      led mike
      wrote on last edited by
      #2

      Trustapple wrote:

      how can i read that it is a thursday from datetime picker.

      Look at this[^] And then this[^]

      led mike

      T 1 Reply Last reply
      0
      • T Trustapple

        Hi, I am creating an applicatio that creates databases on the date provided. I have a problem. I am using datetimepicker for selecting the date. I need the application to create the database if teh day of the selected date is Thursday only.Otherwise it should show a message box saying "The selecetd day is not Thursday Do you want to continue or not". How can i do this? public string GetDatabasename() { string namedatabase = dateTimePicker1.Value.ToString("MMdd"); string nameDB = "CustList_PGE_" + namedatabase; MessageBox.Show("The name of the database will be CustList_PGE_" + namedatabase); return nameDB; } The above mentioed code takes the month and day. My datetime picker display is like Thursday February 28,2008 Planning to do it like if in the datetimepicker if its Thursday ,then it will go to a if statement and show the message box. But my problem is how can i read that it is a thursday from datetime picker. Thanking You,

        J Offline
        J Offline
        J4amieC
        wrote on last edited by
        #3

        This really is all in the documentation. The Value property of DatTimePicker returns a DateTime instance which has a DayOfWeek[^] property which is an enumeration if(myDateTimePicker.Value.DayOfWeek == DayOfWeek.Thursday) { // do something }

        N 1 Reply Last reply
        0
        • L led mike

          Trustapple wrote:

          how can i read that it is a thursday from datetime picker.

          Look at this[^] And then this[^]

          led mike

          T Offline
          T Offline
          Trustapple
          wrote on last edited by
          #4

          Thanks Mike. I did like this if (dateTimePicker1.Value.DayOfWeek.ToString().Equals("The selected date is Thursday")) { MessageBox.Show("Thursday"); } else MessageBox.Show("The selected date is not Thursday,Do you want to continue?", "Options", MessageBoxButtons.YesNo); } I have one more doubt; Is it possible for me to stop the process if i click on "No" in the message box? If yes How? Thanking You,

          L 1 Reply Last reply
          0
          • T Trustapple

            Thanks Mike. I did like this if (dateTimePicker1.Value.DayOfWeek.ToString().Equals("The selected date is Thursday")) { MessageBox.Show("Thursday"); } else MessageBox.Show("The selected date is not Thursday,Do you want to continue?", "Options", MessageBoxButtons.YesNo); } I have one more doubt; Is it possible for me to stop the process if i click on "No" in the message box? If yes How? Thanking You,

            L Offline
            L Offline
            led mike
            wrote on last edited by
            #5

            Read J4amieC's reply, it's important

            Trustapple wrote:

            If yes How?

            Read the documentation for MessageBox.Show(), it answers your question.

            led mike

            1 Reply Last reply
            0
            • J J4amieC

              This really is all in the documentation. The Value property of DatTimePicker returns a DateTime instance which has a DayOfWeek[^] property which is an enumeration if(myDateTimePicker.Value.DayOfWeek == DayOfWeek.Thursday) { // do something }

              N Offline
              N Offline
              Not Active
              wrote on last edited by
              #6

              J4amieC wrote:

              This really is all in the documentation.

              No!!! Not the documentation!! How cruel of them to put the answers there. ;)


              only two letters away from being an asset

              1 Reply Last reply
              0
              Reply
              • Reply as topic
              Log in to reply
              • Oldest to Newest
              • Newest to Oldest
              • Most Votes


              • Login

              • Don't have an account? Register

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • World
              • Users
              • Groups