Help about date

  • Hi

    i am italian and i use sql express edition , i have som table imported frm access in a sql express db.

    My question is how can i use date like this 21/02/2007 0.00.00

    in WHERE condition?

    for exemple for this query:

    UPDATE  Sales_Journal_Storico

    SET  Annullato = CONVERT(datetime, '08/01/2007 13.45.25', 101), Note_Annullamento = '(Annullato per Modifica)', 

    User_Annullamento = '*Upd*sdf038/SDF038DUO'

    WHERE     Date = CONVERT(datetime, '07/27/2007', 101) AND [Invoice/CM #] = '16790_26612' AND [Credit Memo] = 'FALSE' AND Annullato IS NULL

    This query don't function and all my research on web don't satisfied me

    PLEASE somebody have some exemple?

    Thanks a lot

    Fabrizio

  • I don't have Italian Windows / Sqlserver settings, so it's a bit of guessing, but ...

    I think the problem could be in the dot in the timepart.

    Did you try CONVERT(datetime, '08/01/2007 13:45:25', 101)?

  • Thanks a lot is correct!

    ps:Where you came from?

    Fabrizio

  • From the Netherlands.

    We have a similar system as Italia for datetime syntax:

    eg 31-07-2007 14:23:46.000

    Btw: try to use ISO standard dates, SqlServer accepts these for every (country) setting

  • If you look up "Convert Function" in Books Online, it will give you all the codes for converting a datetime to your proper format.  For the Italian format version, the code is 105 (dd-mm-yyyy) and U.S. standard is 101. 

    You might also look into changing the collation for your datetime columns (or your entire datbase) so you don't have to do the convert functions.  Search on the term "column-level collations" for more details.

    Brandie Tarvin, MCITP Database AdministratorLiveJournal Blog: http://brandietarvin.livejournal.com/[/url]On LinkedIn!, Google+, and Twitter.Freelance Writer: ShadowrunLatchkeys: Nevermore, Latchkeys: The Bootleg War, and Latchkeys: Roscoes in the Night are now available on Nook and Kindle.

Viewing 5 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic. Login to reply