sql >> Database teknologi >  >> RDS >> Sqlserver

SQL Server:beregner datointervaller

SELECT  'Anything' as Label
        ,DATEADD(month, DATEDIFF(month, 0, GETDATE()), 0) as firstdaythismonth
        ,DATEADD(day, DATEDIFF(day, 0, GETDATE()), 0) as today
        ,DATEADD(year, -1, DATEADD(month, DATEDIFF(month, 0, GETDATE()), 0)) as firstdaythismonth_lastyear
        ,DATEADD(year, -1, DATEADD(day, DATEDIFF(day, 0, GETDATE()), 0)) as today_lastyear


  1. Hvordan forhindrer du SQL-injektion i LAMP-applikationer?

  2. MAKEDATE() Eksempler – MySQL

  3. Postgresql ændre kolonnetype fra int til UUID

  4. MariaDB JSON_KEYS() Forklaret