Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Getting the current date in SQL Server

I searched but wasn't able to find the way to get the date in this format (DD.MM.YYYY) Help me please change this request:

DECLARE @date datetime
set @date = '01.05.2016'
SELECT [User], cast(DATEADD(SECOND, sum(datediff(DAY, @date,[Start])),@date) as date)'Date'
      ,cast(DATEADD(SECOND, sum(datediff(SECOND, '00:00:00',[Period])),'00:00:00') as time)'Total time'
  FROM [Table].[TableAction]
  where
   [Start] >= @date+'00:00:00' and [Start] <= @date+'23:59:59'
   group by [USER]
like image 576
Serg Avatar asked Jun 05 '26 01:06

Serg


1 Answers

DECLARE @date datetime set @date = GETDATE()

Now to output it, you need to "Format" it.

select FORMAT (@date,'MM.dd.yy') as date

enter image description here

like image 178
Tschallacka Avatar answered Jun 07 '26 22:06

Tschallacka



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!