Re: Can someone help with this SQL statement

From: Frank Hickman [MVP] (fhickman_NOSP_at_M_noblesoft.com)
Date: 02/19/05


Date: Fri, 18 Feb 2005 22:37:18 -0500


"tawright915" <tawright915@yahoo.com> wrote in message
news:1108767378.197573.267600@g14g2000cwa.googlegroups.com...
> Thanks for the help, but I'm still missing the last digit of the
> millisecond. I tried adding a zero to all parts but that came back
> with an error.
>

Yep, I finally caught the problem. You need to cast the result of the
datepart call to a bigint prior to the multiplication. Try it like so...

INSERT INTO TSK2 (TSK2_DATE_TIME, TSK2_PRIORITY, TSK2_ACTION)
(
SELECT (CAST(DATEPART(YEAR, CURRENT_TIMESTAMP) AS BIGINT)*10000000000000) +
 (CAST(DATEPART(MONTH, CURRENT_TIMESTAMP) AS BIGINT)*100000000000) +
 (CAST(DATEPART(DAY, CURRENT_TIMESTAMP) AS BIGINT)*1000000000) +
 (CAST(DATEPART(HOUR, CURRENT_TIMESTAMP) AS BIGINT)*10000000) +
 (CAST(DATEPART(MINUTE, CURRENT_TIMESTAMP) AS BIGINT)*100000) +
 (CAST(DATEPART(SECOND, CURRENT_TIMESTAMP) AS BIGINT)*1000) +
 (CAST(DATEPART(MILLISECOND, CURRENT_TIMESTAMP)),
 0,
 341
)

Looks better huh?

-- 
============
Frank Hickman
Microsoft MVP
NobleSoft, Inc.
============
Replace the _nosp@m_ with @ to reply.


Relevant Pages

  • Re: Can someone help with this SQL statement
    ... but I'm still missing the last digit of the ... millisecond. ... I tried adding a zero to all parts but that came back ...
    (microsoft.public.vc.database)
  • Time query repost
    ... Sorry to repost this question. ... missing leading the zero, so when it's zero then there are only on digit. ...
    (microsoft.public.sqlserver.programming)
  • Re: Time query repost
    ... I was talking about the question of how to pad with zeros. ... > missing leading the zero, so when it's zero then there are only on digit. ...
    (microsoft.public.sqlserver.programming)
  • Re: Fraudulent eBay listing
    ... digit is never zero. ... Why filter on extraneous characters? ... Plain grep does not use true REs. ...
    (rec.crafts.metalworking)
  • Re: Need modern version of old technique to show missing values
    ... The above-mentioned R has the symbol "NA" to indicate missing values, ... distinguished from the usual IEEE754 floating point special values ... negative zero. ... seem determined to use an older standard this option is of course not ...
    (comp.lang.fortran)

Loading