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. Visual Basic
  4. datepart funtion Problem

datepart funtion Problem

Scheduled Pinned Locked Moved Visual Basic
help
5 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.
  • S Offline
    S Offline
    soniasan
    wrote on last edited by
    #1

    select convert(varchar(2),datepart(dd,travel_date))from booking_details this returns me :……. 15 21 24 8 5 But in this o/p I want 08 instead of 8 please suggest

    K S D 3 Replies Last reply
    0
    • S soniasan

      select convert(varchar(2),datepart(dd,travel_date))from booking_details this returns me :……. 15 21 24 8 5 But in this o/p I want 08 instead of 8 please suggest

      K Offline
      K Offline
      kubben
      wrote on last edited by
      #2

      This is the wrong forum for this question, but one answer might be: select right('0'+convert(varchar(2),datepart(dd,travel_date)),2) from booking_details Hope that helps. Ben

      S 1 Reply Last reply
      0
      • S soniasan

        select convert(varchar(2),datepart(dd,travel_date))from booking_details this returns me :……. 15 21 24 8 5 But in this o/p I want 08 instead of 8 please suggest

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

        Theres a little CP article here which has near the bottom a nice concise way of doing this http://www.codeproject.com/useritems/sqlpadding.asp[^]

        1 Reply Last reply
        0
        • S soniasan

          select convert(varchar(2),datepart(dd,travel_date))from booking_details this returns me :……. 15 21 24 8 5 But in this o/p I want 08 instead of 8 please suggest

          D Offline
          D Offline
          Dave Kreskowiak
          wrote on last edited by
          #4

          This has nothing to do with VB or VB.NET. Ask this question in the SQL forum.

          A guide to posting questions on CodeProject[^]
          Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
               2006, 2007

          1 Reply Last reply
          0
          • K kubben

            This is the wrong forum for this question, but one answer might be: select right('0'+convert(varchar(2),datepart(dd,travel_date)),2) from booking_details Hope that helps. Ben

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

            Dear Ben Thanks for your help. It's working now.

            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