Date Format
At some point I wanted to get just the date and part of the time from a timestamp column. So I:
left(convert_tz(EventTime,'+00:00','system'), 15)
Which works in MySQL from the terminal, but in Java-based SQL managers like Squirrel you get:
32 30 31 32 2d 30 36 2d 32 31 20 30 34 3a 34
To work around this, or simply to write more bulletproof SQL scripts, wrap your query in a dateformat function, like:
left(date_format(convert_tz(EventTime,'+00:00','system'), '%Y-%m-%d %H:%i:%S'), 15)
2012-06-21 04:4
Written by k2t0f12d
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Sql
Authors
Related Tags
#sql
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#