• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1497
  • Last Modified:

T-SQL month Datepart issue

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
sublimation
Asked:
sublimation
1 Solution
 
Guy Hengel [angelIII / a3]Billing EngineerCommented:
why not do it like this:
CONVERT(VARCHAR(5), BeginTime, 103)

Open in new window

0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now