date problem

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • charvi
    New Member
    • May 2007
    • 121

    date problem

    i have a problem with dates i want to retrieve some records between two dates dates are input to two masked box.i have written the query like this
    rssearch.Open "select * from timesheet where sname like'%" & txtstaffname.Te xt & "%'" & _
    "and date =#" & mskfrom & "#", con, adOpenDynamic, adLockOptimisti c
    if mskfrom value is 01/01/2008 and msk is 04/01/2008
    it gives result of four months but i want only jan 4 days result
    pls help me database is msaccess
  • lotus18
    Contributor
    • Nov 2007
    • 865

    #2
    Originally posted by charvi
    i have a problem with dates i want to retrieve some records between two dates dates are input to two masked box.i have written the query like this

    [code=vb]
    rssearch.Open "select * from timesheet where sname like'%" & txtstaffname.Te xt & "%'" & _
    "and date =#" & mskfrom & "#", con, adOpenDynamic, adLockOptimisti c

    [/code]
    if mskfrom value is 01/01/2008 and msk is 04/01/2008
    it gives result of four months but i want only jan 4 days result
    pls help me database is msaccess

    Hi

    As i can see it seems like that the date format must be Day/Month/Year and not Month/Day/Year . You need Format function for that : )


    Rey Sean
    Last edited by lotus18; Feb 16 '08, 12:29 PM. Reason: omitted "to"

    Comment

    • charvi
      New Member
      • May 2007
      • 121

      #3
      Originally posted by lotus18
      Hi

      As i can see it seems like that the date format must be Day/Month/Year and not Month/Day/Year . You need Format function for that : )


      Rey Sean
      i used format function but still it is not working

      Comment

      • lotus18
        Contributor
        • Nov 2007
        • 865

        #4
        Originally posted by charvi
        i used format function but still it is not working
        May I see the codes.BTW, have you checked the format of your date on your database?

        Rey Sean

        Comment

        • charvi
          New Member
          • May 2007
          • 121

          #5
          Originally posted by lotus18
          May I see the codes.BTW, have you checked the format of your date on your database?

          Rey Sean
          but in database it stores in dd/mm/yyyy.but only after executing the query it compares with mm/dd/yyyy i used format function also
          can any one help

          Comment

          • charvi
            New Member
            • May 2007
            • 121

            #6
            Originally posted by charvi
            but in database it stores in dd/mm/yyyy.but only after executing the query it compares with mm/dd/yyyy i used format function also
            can any one help
            i have coded like this and my database stores data in dd/mm/yyyy format
            but when i enter dates in textbox in dd/mm/yyyy format
            for eg 01/01/2008 and 04/012008
            here it compares o4 as month
            and gives result upto april but iwant records till jan 4
            can any one help

            Comment

            • mafaisal
              New Member
              • Sep 2007
              • 142

              #7
              Hello,

              U Have Better to Use DTPicker to Select Date instead of textbox

              Faisal

              Originally posted by charvi
              i have coded like this and my database stores data in dd/mm/yyyy format
              but when i enter dates in textbox in dd/mm/yyyy format
              for eg 01/01/2008 and 04/012008
              here it compares o4 as month
              and gives result upto april but iwant records till jan 4
              can any one help

              Comment

              • charvi
                New Member
                • May 2007
                • 121

                #8
                Originally posted by mafaisal
                Hello,

                U Have Better to Use DTPicker to Select Date instead of textbox

                Faisal
                i used msk editor i cannot use date picker because some times a vaule is not entered

                Comment

                • lotus18
                  Contributor
                  • Nov 2007
                  • 865

                  #9
                  Can you post some of your codes here?

                  What do you mean by this?

                  Originally posted by charvi
                  i used msk editor i cannot use date picker because some times a vaule is not entered
                  You can do a validation for that.

                  Comment

                  • 9815402440
                    New Member
                    • Oct 2007
                    • 180

                    #10
                    hi

                    open control panel and then open regional and language settings. here change short date format to dd/MM/yyyy.
                    this will solve your problam

                    regards
                    manpreet singh dhillon hoshiarpur

                    Comment

                    • Killer42
                      Recognized Expert Expert
                      • Oct 2006
                      • 8429

                      #11
                      Actually, it's quite simple. The database does not store dates in dd/mm/yyy, or mm/dd/yyyy, or any other such format. It simply stores a number. The formatting is only used in passing values to and fro, since they have to be placed in a string, and need to make sense to the reader.

                      The SQL interpreter (at least for Access, not sure about other DBMSs) requires American format. So take your date value and format it as mm/dd/yyyy when placing it in the SQL's WHERE clause. You can display it in whatever format you like. Generally it's best to use the Windows settings if possible, so that the end-user is not locked into what you consider the right format.

                      Where possible, I recommend using a less ambiguous format to prevent this sort of issue. For example, dd-mmm-yyyy (Eg. 21-Jan-2007). There's not much chance of getting the day and month mixed up in this case.

                      Manpreet, I think expecting everyone to set their Windows date format the same seems a bit unreasonable.

                      Comment

                      • debasisdas
                        Recognized Expert Expert
                        • Dec 2006
                        • 8119

                        #12
                        Originally posted by charvi
                        i used msk editor i cannot use date picker because some times a vaule is not entered
                        You can use the checkbox option of the control.

                        Comment

                        Working...