Results 1 to 3 of 3

Thread: Dates format

  1. #1

    Thread Starter
    Member Octopus's Avatar
    Join Date
    Jan 2006
    Posts
    48

    Dates format

    Dear All,
    I would like to compare a selected Date with a range of dates in sqlserver database.
    The date format is dd/mm/yyyy and computer system date is also the same.
    but the problem is when i run the query it doesn't return a result but if
    the matching date was in the format mm/dd/yyyy the query will return the
    date.

    the database collation is latin_general.

    I need the query to match the date format dd/mm/yyyy

    so how can i solve the problem??

  2. #2
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: Dates format

    You can use DatePart or Month, Day, Year concatenated to make your needed format. Or you can Cast or Convert it the the date format you need. All can be done in the sql query.
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  3. #3
    MS SQL Powerposter szlamany's Avatar
    Join Date
    Mar 2004
    Location
    Connecticut
    Posts
    18,263

    Re: Dates format

    Quote Originally Posted by Octopus
    Dear All,
    I would like to compare a selected Date with a range of dates in sqlserver database.
    The date format is dd/mm/yyyy and computer system date is also the same.
    but the problem is when i run the query it doesn't return a result but if
    the matching date was in the format mm/dd/yyyy the query will return the
    date.

    the database collation is latin_general.

    I need the query to match the date format dd/mm/yyyy

    so how can i solve the problem??
    Dates are displayed in those formats.

    In MS SQL dates are stored as integer values.

    Your problem is related to how you are formatting dates between VB and the query.

    Show some code and we can deal with the actual issue.

    *** Read the sticky in the DB forum about how to get your question answered quickly!! ***

    Please remember to rate posts! Rate any post you find helpful - even in old threads! Use the link to the left - "Rate this Post".

    Some Informative Links:
    [ SQL Rules to Live By ] [ Reserved SQL keywords ] [ When to use INDEX HINTS! ] [ Passing Multi-item Parameters to STORED PROCEDURES ]
    [ Solution to non-domain Windows Authentication ] [ Crazy things we do to shrink log files ] [ SQL 2005 Features ] [ Loading Pictures from DB ]

    MS MVP 2006, 2007, 2008

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width