Custom TimeSpan Format with escape \ for TIME foramt


When you use format function to format time, it will error out with style which will work with datetime.
select format(cast(’05:59′ as datetime), N’hh:mm’) — works
select format(cast(’05:59′ as time), N’hh:mm’) — returns NULL

The following will work with customized format (escape the : and . if there is any)

select format(cast(’05:59′ as time), N’hh\:mm’) –works

https://msdn.microsoft.com/en-US/library/ee372287
https://msdn.microsoft.com/en-US/library/ee372286?f=255&MSPPError=-2147217396

Advertisements


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s