SQL Server Insert a DATETIME value with only MONTH and YEAR

w41d8nur  于 2023-08-02  发布在  其他
关注(0)|答案(1)|浏览(103)

I'm writing a stored procedure in SQL Server and I need to insert a value into DATETIME column with input of MONTH and YEAR .

Example: Input MONTH = 7, YEAR = 2023, the result is:
| DATETIME |
| ------------ |
| 2023-07-01 00:00:00.000 |

The DAY value is 01 when insert new record.

jjjwad0x

jjjwad0x1#

I got the answer. Use function DATEFROMPARTS(@Year, @Month, 1)

相关问题