Page 2 of 2 FirstFirst 12
Results 41 to 51 of 51

Thread: select statement(Resolved)

  1. #41
    Banned dglienna's Avatar
    Join Date
    Jun 2004
    Location
    Center of it all
    Posts
    17,901

    Re: select statement

    If the format is not going to change, then text dates may be the best.

  2. #42
    Fanatic Member
    Join Date
    Mar 2002
    Location
    AUSTRALIA
    Posts
    603

    Re: select statement

    When I use the date ranges you last mentioned, I get correct results..
    I have attached screen shots.
    Also a shot of the DB contents for others to see.

    What country are you in ? (relates to your Windows Date settings)
    It really is a 'lucky dip' as to what VB and Access and Windows decide to do when they are interpreting your DD/MM/YYYY
    Try editing your dates in the DB from 04/04/2005 to 04/Apr/2005
    Do that with the other dates, and run the pgm again.
    If it then works, then you know you should not trust the system's guess at what ../04/.... means. You should use ../Apr/.... instead.
    Attached Images Attached Images    
    Rob C

  3. #43
    Fanatic Member
    Join Date
    Mar 2002
    Location
    AUSTRALIA
    Posts
    603

    Re: select statement

    I am attaching the Original and the one I tweaked.
    I have also used .MoveFirst to ensure that the loop through records is picking up all records. (On my runs, it made no difference, but it is a good habit).
    Attached Files Attached Files
    Rob C

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

    Re: select statement

    Quote Originally Posted by RobCrombie
    Try editing your dates in the DB from 04/04/2005 to 04/Apr/2005
    Do that with the other dates, and run the pgm again.
    What exactly do you mean by this?

    Dates cannot be edited and stored differently in a DB - they are stored in a quadword format that has nothing to do with the display presentation you see.

    Most of the confusion I've seen on the forum about dates is directly related to this point. People think they are seeing dates a certain way and then construct weak queries around those assumptions.

    I agree with you completely that using an APR instead of 04 format for month is clearly less ambiguous and will probably work for this person...

    It's all about coming up with a date formatting concept that works and then using it consistently.

    *** 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

  5. #45
    Fanatic Member
    Join Date
    Mar 2002
    Location
    AUSTRALIA
    Posts
    603

    Re: select statement

    OOPS
    You are correct.

    Normally I wouldn't be tweaking the DB directly like that.

    Probably what I should have said is any dates that are being interpreted by code for storage should use Apr instead of 04, so that the correct date is stored. I did mention earlier that Access stores it internally in it's own way, I just forgot to tell myself that, when I quickly said 'try editing your dates'
    Rob C

  6. #46

    Thread Starter
    Lively Member
    Join Date
    Feb 2005
    Posts
    81

    Re: select statement

    i managed to get it done... Guys, Thanks for all your help.
    Attached Files Attached Files

  7. #47

    Thread Starter
    Lively Member
    Join Date
    Feb 2005
    Posts
    81

    Re: select statement(Resolved)

    RobCrombie,

    i have no idea why your file "orig and ItsBeenRobbed cant work on my PC.

  8. #48
    Fanatic Member
    Join Date
    Mar 2002
    Location
    AUSTRALIA
    Posts
    603

    Re: select statement(Resolved)

    When you say 'cant work on my PC' what exactly happens (or not) ?

    The pgm runs I assume ?
    Just when you select the date range you don't see all the records you expect ?

    I Looked at the solution you last posted, and noticed that you hadn't really solved the International Date settings problem, You had just made individual variations between using DD/MM/YYYY and MM/DD/YYYY in different places in your pgm.
    That was not the way to solve this problem, it is just 'band aiding' it.
    I have just run your pgm now, and I am attaching the results.
    You haven't said which country you are in, but because we are getting mixed results, I can bet it is not Australia.
    So you should either move to Australia, or come up with a solution that is 'fool proof'.

    I am also attaching the contents of your DB. If you study them you will see that my run of your pgm returns the three records that the system is forced into thinking are Apr or May.
    The other two records can be interpreted as being Dec or Nov, and I guess that is what is happening, in an Australian run of your pgm.

    You haven't shown the code that was writing the data to the DB. I am guessing that it is not 'date proof'.

    As I said in my first post, I am frightened of Dates, and have invented an alternative approach which uses Longs', which is 'fool proof'

    I can tell, that you wil not be open to that approach, so instead you should post all of your code, and really l i s t e n to the other experts.
    Attached Images Attached Images   
    Rob C

  9. #49

    Thread Starter
    Lively Member
    Join Date
    Feb 2005
    Posts
    81

    Re: select statement(Resolved)

    hi,

    i m from Malaysia. i get your point. the only thing is i need to change the format before it display on the grid which i havent done it.

    when i run your pgm, i put 03/04/2005 to 30/04/2005, i get the result: 04/04/2005 only

    for 10/04/2005 to 30/04/2005 the result is 24/05/2005

    the result seems totally out of control.

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

    Re: select statement(Resolved)

    Quote Originally Posted by vivian2u
    hi,

    i m from Malaysia. i get your point. the only thing is i need to change the format before it display on the grid which i havent done it.

    when i run your pgm, i put 03/04/2005 to 30/04/2005, i get the result: 04/04/2005 only

    for 10/04/2005 to 30/04/2005 the result is 24/05/2005

    the result seems totally out of control.
    Like I said in my post (#40) - formatting of dates for selection is something that has to be worked out and consistently applied. You will go around in circles if you do not have a firm foundation to work with.

    You must come up with a format (yyyy-mm-dd or dd mmm yyyy or whatever works with your regional settings and version of DB) - determine that it does work and then consistently apply it in your program. This R&D portion of development cannot be skipped over.

    Once you have a format that works, wrap the logic for "formatting" that into a nice FUNCTION buried in a module somewhere - and use that function everywhere for date translation.

    We like to have a function that can translate from "stored" format, "selection" format and "display" format - all with the same function - based on a "output type" parameter.

    *** 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

  11. #51
    Fanatic Member
    Join Date
    Mar 2002
    Location
    AUSTRALIA
    Posts
    603

    Re: select statement(Resolved)

    The 'system' is playing 'russian roulette' with it's guesses.
    You have to make it absolutely 'Fool proof', so it can no longer be allowed to guess.

    You haven't jumped to take up my 'Longs approach'.

    Thus you should let the experts in handling Dates, have a look.

    I'll attach your project(in zip format), so they can more easily open it.

    You should also post the code, that will be used to store the dates into the DB, as it is vital that it be 'Date proof', as well.
    Attached Files Attached Files
    Rob C

Page 2 of 2 FirstFirst 12

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