Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Something went wrong - How to pad?
Message
From
07/12/2001 10:04:15
 
 
To
All
General information
Forum:
Microsoft SQL Server
Category:
SQL syntax
Title:
Something went wrong - How to pad?
Miscellaneous
Thread ID:
00591138
Message ID:
00591138
Views:
65
SELECT DISTINCT TOP 100 PERCENT Member_Id,
   RTRIM(CAST(DATEPART(yyyy, [Interval]) AS char))
   + '.' + RTRIM(CAST(DATEPART(mm, [Interval]) AS char))
   + '.' + RTRIM(CAST(DATEPART(dd, [Interval]) AS char)) AS Dates,
   RTRIM(CAST(DATEPART(hh, [Interval]) AS char))
   + '.' + RTRIM(CAST(DATEPART(mi,[Interval]) AS char))
   + '.' + RTRIM(CAST(DATEPART(ss, [Interval]) AS char)) AS Times
FROM dbo.Detail
What comes back looks like this:
2001.10.16,0.2.0 and I bet if the month or day are single digits it would look like 2001.1.1

What I want is 2001.01.01 00:02:00, i.e something that looks like a date.

Since I have no control over the final interface I need to deliver the data in this format.

How do I pad zeros in front of single digit values?

TIA
Peter Pirker


Whosoever shall not fall by the sword or by famine, shall fall by pestilence, so why bother shaving?

(Woody Allen)
Next
Reply
Map
View

Click here to load this message in the networking platform