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 8700575
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T02:11:50+00:00 2026-06-13T02:11:50+00:00

My dbase has date formats in 6 digits with a int datatype (‘734503’ =

  • 0

My dbase has date formats in 6 digits with a int datatype (‘734503’ = 01/01/2012).
I have been able to successfully convert these to char with:

SELECT CONVERT(char(12),dateadd(dd,(date_paid -    639906),'1/1/1753'),101)  
FROM   vouchers       
WHERE date_paid =    '734503'

This gives me the output of 01/01/2012.
But if I search on the converted date in a query like this:

SELECT CONVERT(char(12),dateadd(dd,(date_paid - 639906),'1/1/1753'),101) 
FROM vouchers    
WHERE date_paid >= '09/01/2012'  AND date_paid <= '09/30/2012'

Why doesn’t the conversion take place? Even if I use a CONVERT in the WHERE statement on the date_paid field, shouldn’t it work there?

I suppose my question is how do I search with the converted character date and not have to use the 6 digit date?

  • 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-06-13T02:11:51+00:00Added an answer on June 13, 2026 at 2:11 am

    Your problem is that you are comparing an INT column with STRING values, and expecting it to resolve as if comparing dates…

    WHERE date_paid >= '09/01/2012'
      AND date_paid <= '09/30/2012' 
    
    -- date_paid is an INT (according to your question)
    -- '09/01/2012' is a STRING
    

    Because of the differing datatypes there is an implicit CAST() in there. Effectively you’re doing…

    WHERE CAST(date_paid AS VARCHAR(10)) >= '09/01/2012'
      AND CAST(date_paid AS VARCHAR(10)) <= '09/30/2012' 
    
    -- NOTE:  All of these values are now strings
    --        They may LOOK like dates, but they're just strings
    

    What you really need to do is explicitly manipulate the strings in to integers.

    WHERE date_paid >= DATEDIFF(DAY, '01/01/1753', '09/01/2012') + 639906
      AND date_paid <= DATEDIFF(DAY, '01/01/1753', '09/30/2012') + 639906
    

    This too involves implicit casts. DATEDIFF() only takes DATETIME datatypes so the strings are implicitly cast to DATETIMEs first.

    EDIT:

    Another option would be to CAST() the date_paid field into a DateTime, then base the WHERE caluse on that. The down side here is…
    – The CAST() would have to be done on every row, then the WHERE clause applied
    – This prevents any use of indexes and dramatically reduces performance

    The answer above does all the manipulation on the constant values, so that the searched field can be processed in it’s native state; thus allowing use of indexes.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a DBase IV database. Each row has a memo field with a
I have a query that displays columns from multiple tables in a test dbase.
I have got a TTable component that uses the BDE to access a DBase
I have a DBGrid that shows a filtered view of a dBASE table. DBGrid
I have an asp.net website that needs to connect to a dBase file on
I know this has been answered before and why this is caused. However, in
I have many tables; each has a primary key which is an Identity column
There has been some discussion on the SO community wiki about whether database objects
I have a MSDOS clipper application that uses dBase as it's database engine, some
I have read several comments here that dBase is a dead system and no

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.