Month and Year function returns INT. So CAST the result to VARCHAR and
concatenate
This may help
SELECT convert(datetime,'01-'+ CAST(month(getdate()) AS
VARCHAR)+'-'+CAST(year(getdate()) AS VARCHAR))
--
Krishnakumar S
[quoted text, click to view] "vanitha" wrote:
> hi,
>
> i want to convert varchar to datetime
>
> example
>
> i want the first date of the month.
>
> convert(datetime,'01-'+month(getdate())+'-'+year(getdate()))
>
> its not working for me.
>
> pls do help me solve this.
>
> thank you
Hi
SELECT DATEADD(MONTH,DATEDIFF(MONTH,0,GETDATE()),0)
[quoted text, click to view] "vanitha" <gvanitha@firstam.com> wrote in message
news:57FE4546-FE2F-412A-9137-9F272159CE14@microsoft.com...
> hi,
>
> i want to convert varchar to datetime
>
> example
>
> i want the first date of the month.
>
> convert(datetime,'01-'+month(getdate())+'-'+year(getdate()))
>
> its not working for me.
>
> pls do help me solve this.
>
> thank you
> vanitha