Hi
How can I trim the seconds off the following datetime example?
6/10/2002 15:57:44 PM
I need to put this in my where clause:
Update stage_fact_account
set fire_fee_balance = whjointdata.dbo.stage_fire_fee.stage_fire_fee_bal
from whjointdata.dbo.stage_fire_fee
where whjointdata.dbo.stage_fire_fee.policy_number =
stage_fact_account.policy_number
and whjointdata.dbo.stage_fire_fee.policy_date_time =
stage_fact_account.account_date_time
and whjointdata.dbo.stage_fire_fee.portfolio_set =
stage_fact_account.portfolio_set
Thanks!Hi Patrice,
Select DATEPART(ss,'6/10/2002 15:57:44 PM')
HTH, jens Suessmeyer.|||sorry, i should have been more precise - I just want the month, day, year,
and minutes, but not the seconds....
"Jens" wrote:
> Hi Patrice,
> Select DATEPART(ss,'6/10/2002 15:57:44 PM')
>
> HTH, jens Suessmeyer.
>|||In that case, use CONVERT (CHAR(16), YourDateColumn, 120) to make it into a
string that truncates the seconds.
RLF
"Patrice" <Patrice@.discussions.microsoft.com> wrote in message
news:C7218353-905B-4505-8AAF-454C50DFA02A@.microsoft.com...
> sorry, i should have been more precise - I just want the month, day, year,
> and minutes, but not the seconds....
> "Jens" wrote:
>|||On Tue, 8 Nov 2005 06:46:13 -0800, Patrice wrote:
>sorry, i should have been more precise - I just want the month, day, year,
>and minutes, but not the seconds....
Hi Patrice,
In addition to Russell's suggestion, you could also use:
SELECT CAST(YourDate AS smalldatetime)
(truncates the seconds)
or
SELECT DATEADD(ss, -DATEPART(ss, YourDate), YourDate)
(rounds to the nearest minute)
Best, Hugo
--
(Remove _NO_ and _SPAM_ to get my e-mail address)
No comments:
Post a Comment