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. Database & SysAdmin
  3. Database
  4. month numbers in sql

month numbers in sql

Scheduled Pinned Locked Moved Database
databasesql-serversysadmintutorialquestion
6 Posts 6 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
    Thanusree Duth
    wrote on last edited by
    #1

    we can get month names by using select datename(mm,getdate()).How to select the month numbers(eg:1,2,3...12) using select statement in sql server?Please suggest the format to select month numbers.

    P P C L R 5 Replies Last reply
    0
    • T Thanusree Duth

      we can get month names by using select datename(mm,getdate()).How to select the month numbers(eg:1,2,3...12) using select statement in sql server?Please suggest the format to select month numbers.

      P Offline
      P Offline
      Pete OHanlon
      wrote on last edited by
      #2

      You can use datepart to retrieve the month number in SQL Server.

      I'm not a stalker, I just know things. Oh by the way, you're out of milk.

      Forgive your enemies - it messes with their heads

      My blog | My articles | MoXAML PowerToys | Onyx

      1 Reply Last reply
      0
      • T Thanusree Duth

        we can get month names by using select datename(mm,getdate()).How to select the month numbers(eg:1,2,3...12) using select statement in sql server?Please suggest the format to select month numbers.

        P Offline
        P Offline
        PIEBALDconsult
        wrote on last edited by
        #3

        Which database system? Doesn't SQL server use DatePart?

        1 Reply Last reply
        0
        • T Thanusree Duth

          we can get month names by using select datename(mm,getdate()).How to select the month numbers(eg:1,2,3...12) using select statement in sql server?Please suggest the format to select month numbers.

          C Offline
          C Offline
          Corporal Agarn
          wrote on last edited by
          #4

          In MS SQL server you can use MONTH(mydate)

          1 Reply Last reply
          0
          • T Thanusree Duth

            we can get month names by using select datename(mm,getdate()).How to select the month numbers(eg:1,2,3...12) using select statement in sql server?Please suggest the format to select month numbers.

            L Offline
            L Offline
            Luc Pattyn
            wrote on last edited by
            #5

            Have your Google powers abandoned you? looking for SQL date functions, you would easily get this page[^] that summarizes it all. :doh:

            Luc Pattyn [Forum Guidelines] [My Articles] Nil Volentibus Arduum

            Please use <PRE> tags for code snippets, they preserve indentation, improve readability, and make me actually look at the code.

            1 Reply Last reply
            0
            • T Thanusree Duth

              we can get month names by using select datename(mm,getdate()).How to select the month numbers(eg:1,2,3...12) using select statement in sql server?Please suggest the format to select month numbers.

              R Offline
              R Offline
              RaviRanjanKr
              wrote on last edited by
              #6

              you can simply use select Month(getdate()) to display month in number.

              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