From: Bob Barrows on
Plamen Ratchev wrote:
> Note that I used CONVERT(DATETIME, <yyyy-mm-dd hh:mi:ss>, 120). If
> you look in BOL style 120 interprets date format exactly in this
> format: yyyy-mm-dd hh:mi:ss. Therefore this is perfectly safe.
>
> The past discussions around here regarding unsafe date formats are
> when you use them without explicitly converting using a predetermined
> style.
D'oh!
Of course. I forgot that you could specify the date format when
converting TO datetime as well as converting FROM it.

--
HTH,
Bob Barrows


From: gv on
Thanks all for your help!!
gv

"gv" <viator.gerry(a)gmail.com> wrote in message
news:uINydN9vKHA.1692(a)TK2MSFTNGP04.phx.gbl...
> Hi all,
>
> I used this to append to a some backups.
>
> DECLARE @DATE VARCHAR(20) = CONVERT(VARCHAR(10),CURRENT_TIMESTAMP,112) +
> '-'
> + RIGHT('00' + CAST(DATEPART(HOUR,CURRENT_TIMESTAMP) AS VARCHAR(10)),2)
> + RIGHT('00' + CAST(DATEPART(MINUTE,CURRENT_TIMESTAMP)AS
> VARCHAR(10)),2)
> + RIGHT('00' + CAST(DATEPART(SECOND,CURRENT_TIMESTAMP)AS
> VARCHAR(10)),2)
>
> How can I convert this back to datetime?
>
> After pasing out of the filename and removing the dash this is what is
> left:
>
> 20100303075951
>
> thanks
> gv
>