Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Something went wrong - How to pad?
Message
De
07/12/2001 10:04:15
 
 
À
Tous
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Syntaxe SQL
Titre:
Something went wrong - How to pad?
Divers
Thread ID:
00591138
Message ID:
00591138
Vues:
66
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)
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform