Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7612463
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T01:55:05+00:00 2026-05-31T01:55:05+00:00

Question on ODBC functions: I need to get the ISO 8601 calendar week from

  • 0

Question on ODBC functions:

I need to get the ISO 8601 calendar week from a SQL datetime.
In SQL-Server, the syntax for that is this:

SELECT DATEPART(ISO_WEEK, GETDATE()) 

in SQL server 2005, ISO_WEEK doesn’t exist, so I have to use a function like this:
http://blogs.lessthandot.com/index.php/DataMgmt/DataDesign/iso-week-in-sql-server

Now my question:
In order to keep it database-independant,
is it possible to get the ISO-calendar week via a ODBC function ?

ODBC-Functions like this (except getdate of course):

SELECT 
 GETDATE() AS vT_SQL_DateTime_NonDeterministic_Function 

,{ fn NOW() } AS vODBC_DateTime_Canonical_Function 
,{ fn CURDATE() } AS vODBC_DateOnly_Canonical_Function 
,CAST(FLOOR(CAST(GETDATE() AS float)) AS datetime) AS vFloor_Mine 
,CONVERT(char(8),  { fn NOW() }, 112) AS v112_ISO 
,CONVERT(char(10), { fn NOW() }, 104) AS v104_Thomas 
,{ fn CONVERT({fn CURDATE()}, SQL_DATE)} AS vODBC_Proper 

-- Testing ODBC functions & syntax
,{ fn CONCAT('abc', 'def')} AS ODBC_Concat
,{ fn CONCAT(NULL, 'def')}  AS ODBC_Concat_NullLeft
,{ fn CONCAT('abc', NULL)}  AS ODBC_Concat_NullRight
,{ fn CONCAT(NULL, NULL)}   AS ODBC_Concat_NullBoth
,{ fn LENGTH('abc')}    AS ODBC_Length
,{ fn UCASE('abc')} AS ODBC_UCASE
,{ fn LCASE('ABC')} AS ODBC_LCASE
,{ fn SUBSTRING('Test me', 1, 4)} AS ODBC_SUBSTRING 
,{ fn LOCATE('in', 'needle in the haystack')}  AS ODBC_Locate 
,{ fn SUBSTRING('Test me', 1, { fn LOCATE(' me', 'Test me') } - 1)} AS ODBC_SUBSTRING_Locate
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T01:55:06+00:00Added an answer on May 31, 2026 at 1:55 am

    Edit: (by question asker)
    And this is the resulting ODBC equivalent, which is the actual answer to my question:

    ({fn DAYOFYEAR({fn TIMESTAMPDIFF(SQL_TSI_DAY, 0, dt) } / 7 * 7 + 3)}+6) / 7 AS ODBC_ISO_WEEK
    

    — End Edit

    Here is a better way to get iso_week in sql-server 2005 or 2000

    CREATE function f_isoweek(@date datetime) 
    RETURNS INT 
    as 
    BEGIN 
    
    RETURN (datepart(DY, datediff(d, 0, @date) / 7 * 7 + 3)+6) / 7 
    
    END 
    

    Read more here:

    Isoweek in SQL Server 2005

    EDIT: After someone claimed my script failed, i added this script proves that it works:

    --This script will run on mssql server 2008, 
    --it will show all rows where isoweek is calculated wrong with the given formular (0 rows)
    
    ;with a as
    (
    select cast('1900-01-01' as datetime) d
    union all
    select dateadd(day, 1, d) from a
    where d < '2100-01-01'
    )
    select count(*) 
    from a 
    where (datepart(DY, datediff(d, 0, d) / 7 * 7 + 3)+6) / 7
    <> datepart(iso_week, d)
    option (maxrecursion 0)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Nightly, I need to fill a SQL Server 2005 table from an ODBC source
I am migrating data from a Oracle on VMS that accesses data on SQL
I have an Access 2003 database that connects to a SQL Server 2008 box
I am trying to display some information from SQL Server to my PHP site.
How do I get ms-access to connect (through ODBC) to an ms-sql database as
I'm trying to connect to SQL Server 2008 R2 from a C++ application as
Question: I need a equivalent of Microsoft Reporting Service, that works on Linux. Free
and once again an axapta-question ( running on ax 2009 and sql-server 2008 r2
I work with SQL Server database with ODBC, C++. I want to detect modifications
I came across this question after searching for a ODBC or JDBC. To my

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.