•3 años
¿Cómo puedo seleccionar el primer día de un mes en SQL?
```texto simple SELECT DATEADD(mes, DATEDIFF(mes, 0, @mydate), 0) AS StartOfMonth ``` ¿Funcionará?
```texto simple SELECT DATEADD(mes, DATEDIFF(mes, 0, @mydate), 0) AS StartOfMonth ``` ¿Funcionará?
Show original content
4 users upvote it!
2 answers
Populares

This can be done a bit easier:
SELECT DATEADD (DAY, -DAY (@mojadata) + 1, @ mojadata) as Beginning of the month
SELECT DATEADD (DAY, -DAY (@mojadata) + 1, @ mojadata) as Beginning of the month
This can be done a bit easier:
SELECT DATEADD (DAY, -DAY (@mojadata) + 1, @ mojadata) as Beginning of the month
SELECT DATEADD (DAY, -DAY (@mojadata) + 1, @ mojadata) as Beginning of the month
Machine translated
2 likes

html Yes, the SQL query provided will work to retrieve the first day of the month for a given date (@mydate).
html Yes, the SQL query provided will work to retrieve the first day of the month for a given date (@mydate).
Machine translated