Solved

T-SQL month  Datepart issue

Posted on 2008-10-10
1
1,477 Views
Last Modified: 2010-05-18
Hi, I have a datatype of DateTime.

I want to parse out parts of the value to build my custom string, e.g.
cast(datepart(dd, BeginTime) as char(2)) + '/' + cast(datepart(mm, BeginTime) as char(2))

Problem is I only seem to be able to get the month in a 1 number format, I want august to be 08 and not just 8.  Thought this would be very easy but I am stuck.

any ideas?

Thanks.
0
Comment
Question by:sublimation
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 143

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 250 total points
ID: 22685718
why not do it like this:
CONVERT(VARCHAR(5), BeginTime, 103)

Open in new window

0

Featured Post

Webinar: Aligning, Automating, Winning

Join Dan Russo, Senior Manager of Operations Intelligence, for an in-depth discussion on how Dealertrack, leading provider of integrated digital solutions for the automotive industry, transformed their DevOps processes to increase collaboration and move with greater velocity.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
SQL Syntax to get a value associated with most recent date 16 64
T-SQL: Need to trim a single leading space 7 63
relocating SQL 2000 18 38
SQL Query 20 25
Confronted with some SQL you don't know can be a daunting task. It can be even more daunting if that SQL carries some of the old secret codes used in the Ye Olde query syntax, such as: (+)     as used in Oracle;     *=     =*    as used in Sybase …
In this article we will get to know that how can we recover deleted data if it happens accidently. We really can recover deleted rows if we know the time when data is deleted by using the transaction log.
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…
Finding and deleting duplicate (picture) files can be a time consuming task. My wife and I, our three kids and their families all share one dilemma: Managing our pictures. Between desktops, laptops, phones, tablets, and cameras; over the last decade…

751 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question