question

Mkhomiak avatar image
Mkhomiak asked

Date conversion

Hello, how can I convert a date to first be the first of the month and then to a string. For example:

2023-03-16 to 2023-03-01


Thank you in advance!

selectdatestringconvertsqlquery
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

1 Answer

·
anthony.green avatar image
anthony.green answered

Take a look at some of the common date routines here for this sort of thing.
https://www.sqlservercentral.com/blogs/some-common-date-routines

As for making it a string, let the front end do that, visualisation things like that should be in the GUI not in the DB.
Dates should be treated as dates, and not strings.

1 comment
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Jeff Moden avatar image Jeff Moden commented ·
Heh... except when there is no GUI. ;)
0 Likes 0 ·

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.