1

Topic: DATE

How to write down  record in MS sql?
to_char (trunc (s.date_called, ' HH24 '), ' HH24:MI "-" ') || to_char (trunc (s.date_called, ' HH24 ') +1/24, ' HH24:MI ')

2

Re: DATE

Patucho;
It, certainly, everyone the first skul-servershchik understands yours oraklovo-postgrishnye  on operation with date and its conversion at line and is reverse...

3

Re: DATE

Patucho;
CONVERT

4

Re: DATE

What is not clear?
It is necessary to define an action cycle date_called if column data type datetime
Let's admit: action date ' 2017-10-01 08:35:30:000 ' it is equal ' 08:00 - 09:00'

5

Re: DATE

iiyama;
Yes there, as a matter of fact, all that is necessary for the person is from current time to receive value of current hour and to generate character "range" from current hour to the following.
That is, if now at us current time 16:10 on an output the type string literal is required to the author: ' 16:00 - 17:00'

6

Re: DATE

Patucho;
It is clear you, it is clear to me. It is clear to any who worked with Orakle or .
But check, if the person saw only MS a SQL Server - to it your literary trash is not clear... As well as you not at once  in the answer received here to your question.

7

Re: DATE

Patucho wrote:

That is not clear?
It is necessary to define an action cycle date_called if column data type datetime
Let's admit: action date ' 2017-10-01 08:35:30:000 ' it is equal ' 08:00 - 09:00 '

DECLARE @p INT = DATEPART (HOUR, GETDATE ());
DECLARE @n INT = @p+1
DECLARE @s_p VARCHAR (2) = RIGHT (' 0 ' + CONVERT (VARCHAR, @p), 2)
DECLARE @s_n VARCHAR (2) = RIGHT (' 0 ' + CONVERT (VARCHAR, @n), 2)
SELECT @s_p + ':00 - ' + @s_n + ':00'

8

Re: DATE

Patucho;

DATEPART (hh, GETDATE ()), DATEPART (hh, DATEADD (hh, 1, GETDATE ()))

9

Re: DATE

Kind  - Eh;
Thanks! Further I will explain more detailed

10

Re: DATE

Girls for beauty of the code smile

declare @d as datetime = getdate ()
select
@d as [moment]
,format (@d, ' HH:00 ') + ' - ' + format (dateadd (hour, 1, @d), ' HH:00 ') as [period]

Function FORMAT is accessible from a SQL Server 2012.

11

Re: DATE

tashkafox wrote:

Girls for beauty of the code smile

just for fun)

declare @h int = datepart (hh, getdate ())
select format (@h*100 + (h+1) %24, ' 00:\0\0 - 00:\0\0 ')

12

Re: DATE

dies irae;
Your kung fu impressed me! I so am not able.
And meeting in another's code, without start would not understand that it the author wanted to tell.