Re: Truncate Statement



FYI, it will be a little more complex than this since you want to reference
the dates from another column in another table, but the general idea is use
the DatePart(month, ...) to get the month out of a date. Thanks.

"Michael C#" <howsa@xxxxxxxxxxx> wrote in message
news:%23dPrNSEcFHA.228@xxxxxxxxxxxxxxxxxxxxxxx
> ... WHERE DatePart(month, [date_column]) = DatePart(month, GetDate())
> or
> ... WHERE DatePart(month, [date_column]) = DatePart(month,
> Current_Timestamp)
>
>
> "Granville" <Granville@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
> news:6DFF2B51-31AE-4906-B3BE-D5B017647309@xxxxxxxxxxxxxxxx
>> Good day everyone
>>
>> I have two SQL tables. One is a "Data" table in it with the days in the
>> dd/mm/yyy format.
>>
>> Another "Time" table has the
>> dd/mm/yyy , Month, Quarter , Year in it.
>>
>> I want to truncate the "Data" table but only where the Month is equal to
>> current month.
>> Rather than putting in a string "manually" I want the truncate statement
>> to
>> pick up today's date, look in the "Time" table, pick up the month that
>> current day belongs to and truncate all those days out of the "Data"
>> table.
>>
>> I've not even started so any ideas will be welcomed?
>>
>> Thanks
>>
>> Granville
>>
>
>


.


Loading