Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
DatePart question
Message
De
03/06/2010 03:22:11
Cetin Basoz
Engineerica Inc.
Izmir, Turquie
 
 
À
02/06/2010 18:29:24
Timothy Bryan
Sharpline Consultants
Conroe, Texas, États-Unis
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Syntaxe SQL
Divers
Thread ID:
01467122
Message ID:
01467171
Vues:
50
>Hi all,
>
>It appears to me everyone went home early today.
>
>I am needing to concat a couple pieces from the current date to a zipcode field to create a pass phrase for a special purpose. My zipcode field is a char(5) so I am wondering if DatePart(dd, GETDATE()) and DatePart(ms, GETDATE()) end up as string values.
>
>What would be the best way to return a string value of those concatenated to a 5 char zipcode?
>Thanks
>Tim

A question would be in which language:) In T-SQL:
SELECT 
  zipcode+
  right('000'+CAST(datePart(dd, GETDATE()) AS VARCHAR(3)),3)+
  right('000'+CAST(datePart(ms, GETDATE()) AS VARCHAR(3)),3) 
from myTable
ms part is 3 ms sensitive and using dd in this one I assume you don't need anything unique, just a fixed size, fixed format value.
Cetin
Çetin Basöz

The way to Go
Flutter - For mobile, web and desktop.
World's most advanced open source relational database.
.Net for foxheads - Blog (main)
FoxSharp - Blog (mirror)
Welcome to FoxyClasses

LinqPad - C#,VB,F#,SQL,eSQL ... scratchpad
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform