def datetime_extract_sql(self, lookup_type, field_name, tzname):
if settings.USE_TZ:
hr, min = self._get_utcoffset(tzname)
if hr < 0:
field_name = "%s - %s HOURS - %s MINUTES" % (field_name, -hr, -min)
else:
field_name = "%s + %s HOURS + %s MINUTES" % (field_name, hr, min)
if lookup_type.upper() == 'WEEK_DAY':
return " DAYOFWEEK(%s) " % ( field_name ), []
else:
return " %s(%s) " % ( lookup_type.upper(), field_name ), []
# Truncating the date value on the basic of lookup type.
# e.g If input is 2008-12-04 and month then output will be 2008-12-01 00:00:00
# Reference: http://www.ibm.com/developerworks/data/library/samples/db2/0205udfs/index.html
评论列表
文章目录