doug-583247
Mr or Mrs. 500
Points: 575
More actions
April 7, 2009 at 8:09 pm
#155529
I am having difficulty converting a string value which represents MMYY into a Date format.
Assume my string value is 0309 (i.e a credit card expiration date being stored as a string).
I need that converted into a date format, so that I can filter as if it were a date. ( < 03/09 or < 03/31/09)
Any suggestions will be appreciated.
Doug P.
Ken Simmons
SSCertifiable
Points: 7822
April 7, 2009 at 8:21 pm
#973966
You could do something like this...
Select dateadd(m,1,cast(STUFF('0309',3,0,'/01/') as datetime))-1
Just replace the '0309' with your field name.
April 7, 2009 at 9:25 pm
#973978
Thank you so much. That works perfectly. I was not aware of the STUFF command. I can think of several uses for that.
Thanks again,
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply