Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Database & SysAdmin
  3. Database
  4. datetime problem

datetime problem

Scheduled Pinned Locked Moved Database
databasehelptutorial
9 Posts 6 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • N Offline
    N Offline
    niki_nilu
    wrote on last edited by
    #1

    hello i am gayatri patil i have two table tAnalyst and tUser tAnalyst:- UserId varchar(20) notnull CreateDate datetime(8) notnull UpdateDate datetime(8) allow Null tUser table:- UserId varchar(20) notnull firstname varchar(20) notnull lastname varchar(20) notnull i want sql query like join the two tables and search data date wise. my query is-------- select tU.UserID,tU.FirstName,tU.LastName, tU.LastName+''+ tU.FirstName'UserId', tA.UserID,tA.CreateDate, tA.UpdateDate from tAnalyst tA, tUser tU where tU.UserID=tA.UserID and tA.CreateDate = '7/25/2007' in this query i haven't error but data is not display. so pls guide me writeway. regards gayatri Gayatri

    S R K N J 5 Replies Last reply
    0
    • N niki_nilu

      hello i am gayatri patil i have two table tAnalyst and tUser tAnalyst:- UserId varchar(20) notnull CreateDate datetime(8) notnull UpdateDate datetime(8) allow Null tUser table:- UserId varchar(20) notnull firstname varchar(20) notnull lastname varchar(20) notnull i want sql query like join the two tables and search data date wise. my query is-------- select tU.UserID,tU.FirstName,tU.LastName, tU.LastName+''+ tU.FirstName'UserId', tA.UserID,tA.CreateDate, tA.UpdateDate from tAnalyst tA, tUser tU where tU.UserID=tA.UserID and tA.CreateDate = '7/25/2007' in this query i haven't error but data is not display. so pls guide me writeway. regards gayatri Gayatri

      S Offline
      S Offline
      soni uma
      wrote on last edited by
      #2

      1 . Gaytri it may possible that racords are not matche 2. Or Pass the Date as 07/25/2007 not 7/25/2007 Old tA.CreateDate = '7/25/2007' i think it is problem New tA.CreateDate = '07/25/2007'

      N 1 Reply Last reply
      0
      • N niki_nilu

        hello i am gayatri patil i have two table tAnalyst and tUser tAnalyst:- UserId varchar(20) notnull CreateDate datetime(8) notnull UpdateDate datetime(8) allow Null tUser table:- UserId varchar(20) notnull firstname varchar(20) notnull lastname varchar(20) notnull i want sql query like join the two tables and search data date wise. my query is-------- select tU.UserID,tU.FirstName,tU.LastName, tU.LastName+''+ tU.FirstName'UserId', tA.UserID,tA.CreateDate, tA.UpdateDate from tAnalyst tA, tUser tU where tU.UserID=tA.UserID and tA.CreateDate = '7/25/2007' in this query i haven't error but data is not display. so pls guide me writeway. regards gayatri Gayatri

        R Offline
        R Offline
        r a j u u
        wrote on last edited by
        #3

        in tA.CreateDate column you can make '07/25/2007'..i think this'7/25/2007'time format wrong...plz try this

        1 Reply Last reply
        0
        • N niki_nilu

          hello i am gayatri patil i have two table tAnalyst and tUser tAnalyst:- UserId varchar(20) notnull CreateDate datetime(8) notnull UpdateDate datetime(8) allow Null tUser table:- UserId varchar(20) notnull firstname varchar(20) notnull lastname varchar(20) notnull i want sql query like join the two tables and search data date wise. my query is-------- select tU.UserID,tU.FirstName,tU.LastName, tU.LastName+''+ tU.FirstName'UserId', tA.UserID,tA.CreateDate, tA.UpdateDate from tAnalyst tA, tUser tU where tU.UserID=tA.UserID and tA.CreateDate = '7/25/2007' in this query i haven't error but data is not display. so pls guide me writeway. regards gayatri Gayatri

          K Offline
          K Offline
          Krish KP
          wrote on last edited by
          #4

          Data stored in CreatedDate colum is DateTime i.e. the column has both date and Time. but while retrieving you are using only Date. so Automatically system takes time as "00:00:00" change you condition to ... ta.CreateDate BETWEEN '25-Jul-2007' AND '26-Jul-2007'

          Regards KP

          1 Reply Last reply
          0
          • N niki_nilu

            hello i am gayatri patil i have two table tAnalyst and tUser tAnalyst:- UserId varchar(20) notnull CreateDate datetime(8) notnull UpdateDate datetime(8) allow Null tUser table:- UserId varchar(20) notnull firstname varchar(20) notnull lastname varchar(20) notnull i want sql query like join the two tables and search data date wise. my query is-------- select tU.UserID,tU.FirstName,tU.LastName, tU.LastName+''+ tU.FirstName'UserId', tA.UserID,tA.CreateDate, tA.UpdateDate from tAnalyst tA, tUser tU where tU.UserID=tA.UserID and tA.CreateDate = '7/25/2007' in this query i haven't error but data is not display. so pls guide me writeway. regards gayatri Gayatri

            N Offline
            N Offline
            neeraj_indianic
            wrote on last edited by
            #5

            This is because of format of date is different in your table column field(i.e. CreateDate and you are comparing this date with another format which is mm/dd/yyyy. If you want to do it then you have to convert your format and you will sure get result. Now use this query to get the result. select tU.UserID,tU.FirstName,tU.LastName, tU.LastName+''+ tU.FirstName'UserId', tA.UserID,tA.CreateDate, tA.UpdateDate from tAnalyst tA, tUser tU where tU.UserID=tA.UserID and convert(varchar,tA.CreateDate,101)='07/25/2007'

            N 1 Reply Last reply
            0
            • S soni uma

              1 . Gaytri it may possible that racords are not matche 2. Or Pass the Date as 07/25/2007 not 7/25/2007 Old tA.CreateDate = '7/25/2007' i think it is problem New tA.CreateDate = '07/25/2007'

              N Offline
              N Offline
              niki_nilu
              wrote on last edited by
              #6

              sir i am write query like you told me. but its not working gayatri Gayatri

              S 1 Reply Last reply
              0
              • N neeraj_indianic

                This is because of format of date is different in your table column field(i.e. CreateDate and you are comparing this date with another format which is mm/dd/yyyy. If you want to do it then you have to convert your format and you will sure get result. Now use this query to get the result. select tU.UserID,tU.FirstName,tU.LastName, tU.LastName+''+ tU.FirstName'UserId', tA.UserID,tA.CreateDate, tA.UpdateDate from tAnalyst tA, tUser tU where tU.UserID=tA.UserID and convert(varchar,tA.CreateDate,101)='07/25/2007'

                N Offline
                N Offline
                niki_nilu
                wrote on last edited by
                #7

                Thanku very much sir your query is running. thanku gayatri Gayatri

                1 Reply Last reply
                0
                • N niki_nilu

                  sir i am write query like you told me. but its not working gayatri Gayatri

                  S Offline
                  S Offline
                  soni uma
                  wrote on last edited by
                  #8

                  Ok then doing This way convert(varchar,tA.CreateDate,101)='07/25/2007'

                  1 Reply Last reply
                  0
                  • N niki_nilu

                    hello i am gayatri patil i have two table tAnalyst and tUser tAnalyst:- UserId varchar(20) notnull CreateDate datetime(8) notnull UpdateDate datetime(8) allow Null tUser table:- UserId varchar(20) notnull firstname varchar(20) notnull lastname varchar(20) notnull i want sql query like join the two tables and search data date wise. my query is-------- select tU.UserID,tU.FirstName,tU.LastName, tU.LastName+''+ tU.FirstName'UserId', tA.UserID,tA.CreateDate, tA.UpdateDate from tAnalyst tA, tUser tU where tU.UserID=tA.UserID and tA.CreateDate = '7/25/2007' in this query i haven't error but data is not display. so pls guide me writeway. regards gayatri Gayatri

                    J Offline
                    J Offline
                    joemonvarghese
                    wrote on last edited by
                    #9

                    hi whenever you are dealing with dates..convert the dates to a common format... you can use convert function for this. regards Joe

                    1 Reply Last reply
                    0
                    Reply
                    • Reply as topic
                    Log in to reply
                    • Oldest to Newest
                    • Newest to Oldest
                    • Most Votes


                    • Login

                    • Don't have an account? Register

                    • Login or register to search.
                    • First post
                      Last post
                    0
                    • Categories
                    • Recent
                    • Tags
                    • Popular
                    • World
                    • Users
                    • Groups