Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Formatting datetime2(3) value
Message
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Syntaxe SQL
Divers
Thread ID:
01681626
Message ID:
01681640
Vues:
45
This message has been marked as a message which has helped to the initial question of the thread.
>Hi everybody,
>
>I've been trying to find some help online as how to get the desired result and could not.
>
>I want to format the datetime2(3) value this way (say, the value is '2019-08-23 13:00:00.000') and I want to format it as
>'20190823_130000.000' using format function and I can not figure out how to do the very last part of correctly showing milliseconds.
>
>Also, I want to be able to do the opposite operation, e.g. from the character value shown in the format above I want to construct the datetime2(3) value correctly. I do have code using several substring which I created, but I was thinking if there is a more efficient and simple way?
>
>Thanks in advance.

Hi,
select stuff(replace(replace(convert(varchar(30), getdate(), 126),':',''),'-',''), 9, 1, '_')
MartinaJ
"Navision is evil that needs to be erazed... to the ground"

Jabber: gorila@dione.zcu.cz
Jabber? Jabbim
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform