#NEWLINE# def date_trunc_sql( self , lookup_type , field_name ) : #NEWLINE# #INDENT# "\n        Given a lookup_type of 'year', 'month' or 'day', returns the SQL that\n        truncates the given date field field_name to a DATE object with only\n        the given specificity.\n        " #NEWLINE# if ( lookup_type == 'year' ) : #NEWLINE# #INDENT# return ( "Convert(datetime, Convert(varchar, DATEPART(year, %s)) + '/01/01')" % field_name ) #NEWLINE# #UNINDENT# if ( lookup_type == 'month' ) : #NEWLINE# #INDENT# return ( "Convert(datetime, Convert(varchar, DATEPART(year, %s)) + '/' + Convert(varchar, DATEPART(month, %s)) + '/01')" % ( field_name , field_name ) ) #NEWLINE# #UNINDENT# if ( lookup_type == 'day' ) : #NEWLINE# #INDENT# return ( 'Convert(datetime, Convert(varchar(12), %s, 112))' % field_name )