Solved

T-SQL month  Datepart issue

Posted on 2008-10-10
1
1,450 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
1 Comment
 
LVL 142

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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Table create permissions on SQL Server 2005 9 40
MySQL left join performance 4 30
SQL join help to a thrid table 51 76
How to base a filter depending on fields contents? 15 47
PL/SQL can be a very powerful tool for working directly with database tables. Being able to loop will allow you to perform more complex operations, but can be a little tricky to write correctly. This article will provide examples of basic loops alon…
Occasionally there is a need to clean table columns, especially if you have inherited legacy data. There are obviously many ways to accomplish that, including elaborate UPDATE queries with anywhere from one to numerous REPLACE functions (even within…
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…

911 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now