sql server - Time query for sql database using Visual Basic -


I want to show maximum time and minimum time for a day in grid control by using Visual Basic from scale database. The table columns are: -

  User ID, Username, Date, Time 1 Shakes 30/1/2009 10:11:22 1 Shakes 30/1/2009 10:15:22 1 Shakes 30 / 1/2009 12:15:22 1 Shakes 30/1/2009 13:15:22  

Output must be in the grid

  1 Shakes 30 / 1/2009 10:11:22 13:15:22  

I go Here is something to believe in your table structure.

  Make TableMbable (UserID Integer, Username varchar (20), [Date] Time of day, [time] varchar (8))  

yours The time is stored as a varchar field because sql2005 does not have any time type, since it will display minimum and maximum time for each user and date. There are two options, if your time is HH: MM: SS then you can use the convert function. The second shows an example of parsing it and builds its own date.

  Select UserID, User Name, [Date], Convert (varchar, MIN (convert (datetime, [time], 108), 108), Convert (Manor, Max (Date Time, [Time], 108)), 108) UserID, UserName, [Date] Select Date [Date] by URIID, UserId, Username, [date], Convert (varchar, MIN (DATEADD (Second, CAST) (Integer as SUBSTRING (time, 7, 2, AS), DATEADD (minutes, CAST (SUBSTRING (time, 4, 2, AS), DATEADD (hour, CAST SUBSTRING (time, 1, 2)) 0))), 108), convert (varchar, MAX (DATEADD ( Second, round (integer as SUBSTRING (time, 7, 2), DATEADD (minutes, cast (integer as time (4, 2), dateADD (hour, CAST (SBBTRI (time, 1, 2) as integer), 0))), 108) user id, username, [date] ORIDER BY user ID, [date]  

Comments

Popular posts from this blog

c# - ListView onScroll event -

PHP - get image from byte array -

Linux Terminal Problem with Non-Canonical Terminal I/O app -