Skip to content

Commit

Permalink
doc for sql's datetrunc()
Browse files Browse the repository at this point in the history
  • Loading branch information
wibeasley authored Dec 3, 2024
1 parent 80587da commit 5da3270
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion R/dates.R
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,12 @@
#' The [sql equivalent](https://docs.microsoft.com/en-us/sql/t-sql/functions/datepart-transact-sql) to `clump_month_date()`
#' is `cast(convert(char(7), getdate(), 126) + '-15' as date)`.
#' The [sql equivalent](https://blog.sqlauthority.com/2007/08/20/sql-server-find-monday-of-the-current-week/) to `clump_week_date()`
#' is `SELECT dateadd(wk, datediff(wk, 0, getdate()), 0)`
#' is `SELECT dateadd(week, datediff(week, 0, getdate()), 0)`.
#' Starting with SQL Server 2022, the [`datetrunc()`](https://learn.microsoft.com/en-us/sql/t-sql/functions/datetrunc-transact-sql?view=sql-server-ver16)
#' function is available.
#' Assume `DECLARE @d date = cast(getdate() as date);`, then it's
#' `SELECT dateadd(day, 14, datetrunc(month, @d))`
#' and `SELECT dateadd(day, 1, datetrunc(week, @d))`.
#'
#' @author Will Beasley
#'
Expand Down

0 comments on commit 5da3270

Please sign in to comment.