Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 5941681
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T16:08:40+00:00 2026-05-22T16:08:40+00:00

Right now, my code has the following conversion for a date field: convert(varchar, Citation.PublishedOn,

  • 0

Right now, my code has the following conversion for a date field:

convert(varchar, Citation.PublishedOn, 101)

However, that returns dates like 03/01/2010. The request was to have the dates display as 3/1/2010 (without the leading zeros, but with a 4 digit year). I’ve looked at http://msdn.microsoft.com/en-us/library/ms187928.aspx and I’m not seeing anything that explicitly excludes leading zeros.

How do I format the date to exclude leading zeros?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T16:08:40+00:00Added an answer on May 22, 2026 at 4:08 pm

    This is how I would do it:

    DECLARE @dt datetime
    SET @dt= Citation.PublishedOn
    SELECT LTRIM(STR(MONTH(@dt)))+'/'+LTRIM(STR(DAY(@dt)))+'/'+STR(YEAR(@dt),4)
    

    You select your date, then extract the day, month and year from it and chop the leading zeroes off the month and day using ltrim().

    If you don’t want to declare a variable, you can do this

    SELECT LTRIM(STR(MONTH(Citation.PublishedOn)))+'/'+LTRIM(STR(DAY(Citation.PublishedOn)))+'/'+STR(YEAR(Citation.PublishedOn),4)
    

    However, that would mean pulling out the same value multiple times.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

right now the source code of my page has the following structure: <span id='648746'
I have some code right now that executes when a link is clicked. The
Right now i have a line of code, in vb, that calls a text
Right now, I have code that looks something like this: Private Sub ShowReport(ByVal reportName
I have an odd edge case right now in that a response code from
I'm stuck with the following scenario. It has a code smell, that I'm not
The web application that I am developing right now has something called quiz engine
The web application that I am developing right now has something called quiz engine
Right now I have an Accordion component in Flex that has two children, I
The web application that I am developing right now has something called quiz engine

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.