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 / C++ / MFC
  4. Need help in DateTimePicker

Need help in DateTimePicker

Scheduled Pinned Locked Moved C / C++ / MFC
helptutorialquestion
8 Posts 3 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.
  • S Offline
    S Offline
    sarat12in
    wrote on last edited by
    #1

    Hi friends.. I need to show date and time both at a time in the DateTimePicker right now i have seen all examples of DateTimePicker show to disply only date r only time at a time. can some one help me how to show date and time both at a time in DateTimePicker. please let me know if it can be done? thank u in advance

    S 1 Reply Last reply
    0
    • S sarat12in

      Hi friends.. I need to show date and time both at a time in the DateTimePicker right now i have seen all examples of DateTimePicker show to disply only date r only time at a time. can some one help me how to show date and time both at a time in DateTimePicker. please let me know if it can be done? thank u in advance

      S Offline
      S Offline
      SandipG
      wrote on last edited by
      #2

      You can set custom format using SetFormat() e.g. from msdn

      CString formatStr= _T("'Today is: 'yy'/'MM'/'dd");
      m_dtPicker.SetFormat(formatStr);

      I hope it helps.

      Regards, Sandip.

      S 1 Reply Last reply
      0
      • S SandipG

        You can set custom format using SetFormat() e.g. from msdn

        CString formatStr= _T("'Today is: 'yy'/'MM'/'dd");
        m_dtPicker.SetFormat(formatStr);

        I hope it helps.

        Regards, Sandip.

        S Offline
        S Offline
        sarat12in
        wrote on last edited by
        #3

        thats really nice idea. and also is there any way that i can show date calender for date and spin control for for time at a time in the UI? i need to show calender for date and spin control for time at a time will that be possible? please let me know

        D 1 Reply Last reply
        0
        • S sarat12in

          thats really nice idea. and also is there any way that i can show date calender for date and spin control for for time at a time in the UI? i need to show calender for date and spin control for time at a time will that be possible? please let me know

          D Offline
          D Offline
          David Crow
          wrote on last edited by
          #4

          sarat12in wrote:

          will that be possible?

          Yes, if you use the DTS_TIMEFORMAT style.

          "Love people and use things, not love things and use people." - Unknown

          "The brick walls are there for a reason...to stop the people who don't want it badly enough." - Randy Pausch

          S 1 Reply Last reply
          0
          • D David Crow

            sarat12in wrote:

            will that be possible?

            Yes, if you use the DTS_TIMEFORMAT style.

            "Love people and use things, not love things and use people." - Unknown

            "The brick walls are there for a reason...to stop the people who don't want it badly enough." - Randy Pausch

            S Offline
            S Offline
            sarat12in
            wrote on last edited by
            #5

            DTS_TIMEFORMAT will only shows the time but not date calender i need to show date calender and time spin control any suggestion please thank you

            S D 2 Replies Last reply
            0
            • S sarat12in

              DTS_TIMEFORMAT will only shows the time but not date calender i need to show date calender and time spin control any suggestion please thank you

              S Offline
              S Offline
              sarat12in
              wrote on last edited by
              #6

              i will go with the first suggestion. but the problem in here is.. if i mention date time format programatically with setFormat , then the display format wont get changed depends on locale its a big problem for me. is there any way that i can get the system format fist and pass it as a string to SetFormat? r is there any other way to handle this scenario? Thanx in advance

              D 1 Reply Last reply
              0
              • S sarat12in

                DTS_TIMEFORMAT will only shows the time but not date calender i need to show date calender and time spin control any suggestion please thank you

                D Offline
                D Offline
                David Crow
                wrote on last edited by
                #7

                If you want both the date and time in the same control, you'll need to use a format string rather than one of the preset formats. See here.

                "Love people and use things, not love things and use people." - Unknown

                "The brick walls are there for a reason...to stop the people who don't want it badly enough." - Randy Pausch

                1 Reply Last reply
                0
                • S sarat12in

                  i will go with the first suggestion. but the problem in here is.. if i mention date time format programatically with setFormat , then the display format wont get changed depends on locale its a big problem for me. is there any way that i can get the system format fist and pass it as a string to SetFormat? r is there any other way to handle this scenario? Thanx in advance

                  D Offline
                  D Offline
                  David Crow
                  wrote on last edited by
                  #8

                  sarat12in wrote:

                  is there any way that i can get the system format fist and pass it as a string to SetFormat?

                  Yes. Use GetDateFormat() and GetTimeFormat().

                  "Love people and use things, not love things and use people." - Unknown

                  "The brick walls are there for a reason...to stop the people who don't want it badly enough." - Randy Pausch

                  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