|
Posted by Roy Harvey on 07/04/07 15:14
To remove the time from a datetime such as getdate():
SELECT dateadd(day,datediff(day,0,getdate()),0)
I strongly suggest not storing a date column as a string. Use a
datetime and just set the time to zeroes if you only need the date.
I even more strongly suggest not using the format dd-mm-yyyy if you do
store a date as a string. YYYYMMDD is much more versatile. For one
thing it will always convert to the datetime type correctly regardless
of country, and for another it will sort in calendar order.
Roy Harvey
Beacon Falls, CT
On Wed, 04 Jul 2007 07:53:34 -0700, Yas <yasar1@gmail.com> wrote:
>Hi,
>
>I am creating creating a table with a Date column dd-mm-yyyy. But I
>cant seem to find a SQL function that just returns today's date.
>getDate() returns the time as well so I cant use it.
>
>The reason is simply that I want to update/overwrite over and over
>again all records from current day but not touch the ones from
>yesterday etc and with the timestamp in there I just end up adding
>more and more rows for the same day.
>
>In other words I only want to preserve rows are from yesterday or
>older but overwrite ones from today.
>
>
>Any help will be appricated.
>
>Thank you!
>
>Yas
Navigation:
[Reply to this message]
|