-
Convert DateTime to Month/Year
Hi.. can you please supply a SQL statement which will convert a datetime value to a Month Year format?
2001-07-17 14:32:20.763 ---> July 2001
thankyou !
Jen
-
Convert DateTime to Month/Year (reply)
select convert(varchar(2),datepart(month,getdate())) + '/' +
convert(varchar(4),datepart(year,getdate()))
getdate is equal to the current date and time. You can also just type in a specific date instead of getdate()
------------
Jennifer at 7/17/01 12:06:24 PM
Hi.. can you please supply a SQL statement which will convert a datetime value to a Month Year format?
2001-07-17 14:32:20.763 ---> July 2001
thankyou !
Jen
-
Convert DateTime to Month/Year (reply)
Jennifer,
Try this --
select substring(convert(char(20), getdate(), 100), 1, 3)
+ ' ' + convert(char(4), year(getdate()))
If you want to convert a variable or a table column, replace getdate() with that name. Hope this helps.
------------
Jennifer at 7/17/01 12:06:24 PM
Hi.. can you please supply a SQL statement which will convert a datetime value to a Month Year format?
2001-07-17 14:32:20.763 ---> July 2001
thankyou !
Jen
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
|