[CS-FSLUG] Great Python Script for SQL Date Formatting

Don Parris evangelinux at thefreelyproject.org
Thu Jul 7 02:04:42 CDT 2005


FYI, here's a great script for converting your standard mm/dd/yyyy format to
SQL's yyy-mm-dd format:

www.uselesspython.com/date2SQL.py

It only searches a single file at a time as is, but sure helped me tonight. 
When doing my date-related functions for Ekklesia earlier, I discovered my
test data had dates of 0000-00-00, which ain't worth a hoot for testing
date-related queries.  

Apparently, when I saved my Calc sheets containing the data set to ASCII
text (TSV), the dates changed from the spreadsheet format (SQL format) to
the standard format - a known issue in pre-2.0 releases of OOo.  Does 2.0
still do this?  The dates are formatted in the Calc sheet the way they
should be, but get converted on save.  Someone suggested changing the locale
settings, but to what I have no idea.

At any rate, date2SQL.py solved my problem for me.  Instead of reinventing
the wheel (writing my own regexp) or wrestling further with OOo, I ran the
script on each file.  I'll have to re-name the files to chop off the
extension the script adds, but that's still a short time.  It's times like
this I really love FLOSS.

Don 
-- 
evangelinux    GNU Evangelist
http://matheteuo.org/                   http://chaddb.sourceforge.net/
"Free software is like God's love - you can share it with anyone anytime
anywhere." 




More information about the Christiansource mailing list