0

How do you use MySQL with YYWW instead of YYYYWW?

My field looks like this:

wYYWW, for example w1310, w1506 and so on.

%x and %X seems to need 4 digits, and therefor it doesn't work.

Is there anyway to solve this problem?

Riad
  • 3,822
  • 5
  • 28
  • 39
user2687506
  • 789
  • 6
  • 21

1 Answers1

1

How about stuffing the characters you need into the string? Something like this:

select str_to_date(insert(col, 1, 1, '20'), '%X%u')
Gordon Linoff
  • 1,242,037
  • 58
  • 646
  • 786
  • Thank you very much! That was exactly what I was looking for! :) (not exactly, since I thought that there was some %x that looked like %y instead of %Y, but it solved the problem! :) ) – user2687506 Feb 07 '15 at 14:27