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. how to get date,month and year from datetime format

how to get date,month and year from datetime format

Scheduled Pinned Locked Moved C#
databasecsharptutorial
3 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.
  • C Offline
    C Offline
    chithra r
    wrote on last edited by
    #1

    hi all good morning.i want to use date,month and year seperately in my application.i can use convert function in sql sever for this purpose,but i dont want to refer database unnecessarily again and again.can anyone tell me how to get only the date month and year from the datetime format in the frontend.(c#).

    pintoo

    P N 2 Replies Last reply
    0
    • C chithra r

      hi all good morning.i want to use date,month and year seperately in my application.i can use convert function in sql sever for this purpose,but i dont want to refer database unnecessarily again and again.can anyone tell me how to get only the date month and year from the datetime format in the frontend.(c#).

      pintoo

      P Offline
      P Offline
      pmarfleet
      wrote on last edited by
      #2

      Did it occur to you to read the documentation? Look at the DateTime class.

      Paul Marfleet "No, his mind is not for rent To any God or government" Tom Sawyer - Rush

      1 Reply Last reply
      0
      • C chithra r

        hi all good morning.i want to use date,month and year seperately in my application.i can use convert function in sql sever for this purpose,but i dont want to refer database unnecessarily again and again.can anyone tell me how to get only the date month and year from the datetime format in the frontend.(c#).

        pintoo

        N Offline
        N Offline
        Nouman Bhatti
        wrote on last edited by
        #3

        System.DateTime moment = new System.DateTime( 1999, 1, 13, 3, 57, 32, 11); // Year gets 1999. int year = moment.Year; // Month gets 1 (January). int month = moment.Month; // Day gets 13. int day = moment.Day; // Hour gets 3. int hour = moment.Hour; // Minute gets 57. int minute = moment.Minute; // Second gets 32. int second = moment.Second; // Millisecond gets 11. int millisecond = moment.Millisecond;

        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