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. Web Development
  3. ASP.NET
  4. Small ordinals?

Small ordinals?

Scheduled Pinned Locked Moved ASP.NET
question
7 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.
  • M Offline
    M Offline
    Member 8761667
    wrote on last edited by
    #1

    Hello The following produces a date in this ordinal format: 30th October 2014:

    Function ReturnDate() As String

        Dim theDate As String = ""
    
        Dim NumericDayofMonth As Integer = Date.Now.Day
        Dim OrdinalSuffix As String = ""
    
        Select Case NumericDayofMonth
            Case 1, 21, 31
                OrdinalSuffix = "st"
            Case 2, 22
                OrdinalSuffix = "nd"
            Case 3, 23
                OrdinalSuffix = "rd"
            Case Else
                OrdinalSuffix = "th"
        End Select
    
        Dim NumericMonthofYear As Integer = Date.Now.Month
        Dim MonthofYear As String = ""
    
        Select Case NumericMonthofYear
            Case 1
                MonthofYear = "January"
            Case 2
                MonthofYear = "February"
            Case 3
                MonthofYear = "March"
            Case 4
                MonthofYear = "April"
            Case 5
                MonthofYear = "May"
            Case 6
                MonthofYear = "June"
            Case 7
                MonthofYear = "July"
            Case 8
                MonthofYear = "August"
            Case 9
                MonthofYear = "September"
            Case 10
                MonthofYear = "October"
            Case 11
                MonthofYear = "November"
            Case 12
                MonthofYear = "December"
        End Select
    
        'Dim NumericDayofWeek As Integer = Date.Now.DayOfWeek
        'Dim DayofWeek As String = ""
    
        'Select Case NumericDayofWeek
        '    Case 1
        '        DayofWeek = "Monday"
        '    Case 2
        '        DayofWeek = "Tuesday"
        '    Case 3
        '        DayofWeek = "Wednesday"
        '    Case 4
        '        DayofWeek = "Thursday"
        '    Case 5
        '        DayofWeek = "Friday"
        '    Case 6
        '        DayofWeek = "Saturday"
        '    Case 7
        '        DayofWeek = "Sunday"
        'End Select
    
        'theDate &= DayofWeek & " " 'Monday, Tuesday, Wednesday etc
        theDate &= DateTime.Now.Day.ToString() '1, 2, 3, 4 etc
        theDate &= OrdinalSuffix & " " 'st, nd, rd, th
        theDate &= MonthofYear & " " 'Jan, Feb etc
        theDate &= DateTime.Now.Year.ToString() '2013, 2014 etc
    
        Return theDate
    End Function
    

    and then, in a sub page_load:

    LblDate.Text = ReturnDate()

    But how would I make the 'st', 'nd', 'rd

    J Richard DeemingR 2 Replies Last reply
    0
    • M Member 8761667

      Hello The following produces a date in this ordinal format: 30th October 2014:

      Function ReturnDate() As String

          Dim theDate As String = ""
      
          Dim NumericDayofMonth As Integer = Date.Now.Day
          Dim OrdinalSuffix As String = ""
      
          Select Case NumericDayofMonth
              Case 1, 21, 31
                  OrdinalSuffix = "st"
              Case 2, 22
                  OrdinalSuffix = "nd"
              Case 3, 23
                  OrdinalSuffix = "rd"
              Case Else
                  OrdinalSuffix = "th"
          End Select
      
          Dim NumericMonthofYear As Integer = Date.Now.Month
          Dim MonthofYear As String = ""
      
          Select Case NumericMonthofYear
              Case 1
                  MonthofYear = "January"
              Case 2
                  MonthofYear = "February"
              Case 3
                  MonthofYear = "March"
              Case 4
                  MonthofYear = "April"
              Case 5
                  MonthofYear = "May"
              Case 6
                  MonthofYear = "June"
              Case 7
                  MonthofYear = "July"
              Case 8
                  MonthofYear = "August"
              Case 9
                  MonthofYear = "September"
              Case 10
                  MonthofYear = "October"
              Case 11
                  MonthofYear = "November"
              Case 12
                  MonthofYear = "December"
          End Select
      
          'Dim NumericDayofWeek As Integer = Date.Now.DayOfWeek
          'Dim DayofWeek As String = ""
      
          'Select Case NumericDayofWeek
          '    Case 1
          '        DayofWeek = "Monday"
          '    Case 2
          '        DayofWeek = "Tuesday"
          '    Case 3
          '        DayofWeek = "Wednesday"
          '    Case 4
          '        DayofWeek = "Thursday"
          '    Case 5
          '        DayofWeek = "Friday"
          '    Case 6
          '        DayofWeek = "Saturday"
          '    Case 7
          '        DayofWeek = "Sunday"
          'End Select
      
          'theDate &= DayofWeek & " " 'Monday, Tuesday, Wednesday etc
          theDate &= DateTime.Now.Day.ToString() '1, 2, 3, 4 etc
          theDate &= OrdinalSuffix & " " 'st, nd, rd, th
          theDate &= MonthofYear & " " 'Jan, Feb etc
          theDate &= DateTime.Now.Year.ToString() '2013, 2014 etc
      
          Return theDate
      End Function
      

      and then, in a sub page_load:

      LblDate.Text = ReturnDate()

      But how would I make the 'st', 'nd', 'rd

      J Offline
      J Offline
      jkirkerx
      wrote on last edited by
      #2

      Have you tried

      OrdinalSuffix = "st"

      I don't know what raised means, but you can use span, an inline element to adjust how it looks http://webdesign.about.com/od/fonts/a/aa082400a.htm[^]

      M 1 Reply Last reply
      0
      • J jkirkerx

        Have you tried

        OrdinalSuffix = "st"

        I don't know what raised means, but you can use span, an inline element to adjust how it looks http://webdesign.about.com/od/fonts/a/aa082400a.htm[^]

        M Offline
        M Offline
        Member 8761667
        wrote on last edited by
        #3

        That's great, jkirkerx. It looks like this now: http://www.bayingwolf.com/Ordinal.jpg[^] Raised means like this: http://www.bayingwolf.com/Raised.jpg[^] Thank you!

        J R 2 Replies Last reply
        0
        • M Member 8761667

          That's great, jkirkerx. It looks like this now: http://www.bayingwolf.com/Ordinal.jpg[^] Raised means like this: http://www.bayingwolf.com/Raised.jpg[^] Thank you!

          J Offline
          J Offline
          jkirkerx
          wrote on last edited by
          #4

          10th October 2014

          th

          1 Reply Last reply
          0
          • M Member 8761667

            Hello The following produces a date in this ordinal format: 30th October 2014:

            Function ReturnDate() As String

                Dim theDate As String = ""
            
                Dim NumericDayofMonth As Integer = Date.Now.Day
                Dim OrdinalSuffix As String = ""
            
                Select Case NumericDayofMonth
                    Case 1, 21, 31
                        OrdinalSuffix = "st"
                    Case 2, 22
                        OrdinalSuffix = "nd"
                    Case 3, 23
                        OrdinalSuffix = "rd"
                    Case Else
                        OrdinalSuffix = "th"
                End Select
            
                Dim NumericMonthofYear As Integer = Date.Now.Month
                Dim MonthofYear As String = ""
            
                Select Case NumericMonthofYear
                    Case 1
                        MonthofYear = "January"
                    Case 2
                        MonthofYear = "February"
                    Case 3
                        MonthofYear = "March"
                    Case 4
                        MonthofYear = "April"
                    Case 5
                        MonthofYear = "May"
                    Case 6
                        MonthofYear = "June"
                    Case 7
                        MonthofYear = "July"
                    Case 8
                        MonthofYear = "August"
                    Case 9
                        MonthofYear = "September"
                    Case 10
                        MonthofYear = "October"
                    Case 11
                        MonthofYear = "November"
                    Case 12
                        MonthofYear = "December"
                End Select
            
                'Dim NumericDayofWeek As Integer = Date.Now.DayOfWeek
                'Dim DayofWeek As String = ""
            
                'Select Case NumericDayofWeek
                '    Case 1
                '        DayofWeek = "Monday"
                '    Case 2
                '        DayofWeek = "Tuesday"
                '    Case 3
                '        DayofWeek = "Wednesday"
                '    Case 4
                '        DayofWeek = "Thursday"
                '    Case 5
                '        DayofWeek = "Friday"
                '    Case 6
                '        DayofWeek = "Saturday"
                '    Case 7
                '        DayofWeek = "Sunday"
                'End Select
            
                'theDate &= DayofWeek & " " 'Monday, Tuesday, Wednesday etc
                theDate &= DateTime.Now.Day.ToString() '1, 2, 3, 4 etc
                theDate &= OrdinalSuffix & " " 'st, nd, rd, th
                theDate &= MonthofYear & " " 'Jan, Feb etc
                theDate &= DateTime.Now.Year.ToString() '2013, 2014 etc
            
                Return theDate
            End Function
            

            and then, in a sub page_load:

            LblDate.Text = ReturnDate()

            But how would I make the 'st', 'nd', 'rd

            Richard DeemingR Offline
            Richard DeemingR Offline
            Richard Deeming
            wrote on last edited by
            #5

            It sounds like you're looking for the <sup> (superscript) element:

            30<sup>th</sup> October 2014

            30th October 2014 There's also a <sub> (subscript) element:

            H<sub>2</sub>O

            H2O


            "These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer

            "These people looked deep within my soul and assigned me a number based on the order in which I joined" - Homer

            M 1 Reply Last reply
            0
            • Richard DeemingR Richard Deeming

              It sounds like you're looking for the <sup> (superscript) element:

              30<sup>th</sup> October 2014

              30th October 2014 There's also a <sub> (subscript) element:

              H<sub>2</sub>O

              H2O


              "These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer

              M Offline
              M Offline
              Member 8761667
              wrote on last edited by
              #6

              [^] Wonderful stuff!! Thank you again!

              1 Reply Last reply
              0
              • M Member 8761667

                That's great, jkirkerx. It looks like this now: http://www.bayingwolf.com/Ordinal.jpg[^] Raised means like this: http://www.bayingwolf.com/Raised.jpg[^] Thank you!

                R Offline
                R Offline
                Rajesh waran
                wrote on last edited by
                #7

                Nice to see the link that you have provided.

                ~R@JEES#

                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