You must Sign In to post a response.
  • Category: .NET

    How to findout this Records in Sql

    Hi

    EMPID DateTime
    1001 30/01/2016 08:15:16
    1002 30/01/2016 12:16:35
    1003 29/01/2016 08:15:55

    How to Time format filtered in Sql Query for ex: grater than 09:00:00

    i need output this

    EMPID DateTime
    1002 30/01/2016 12:16:35
  • #768679
    Hi,

    When you declaring the variable as DateTime obviously you will get the date along with the timestamp.
    So you can directly make it use of the variable in the Where clause without any casting of the variable.


    Select * from TableName where SelectDate >= @DateTime


    So if you SelectDate is like 30/01/2016 12:00:00 (By Default with casting)
    then when you run the above query you will get the desired result.

    Thanks,
    Mani

  • #768696
    You can try this easiest way to findout this Records in Sql

    Select * from dbo.January2017 A where A.Date >= Youtdateandtime;
    or
    select * from tbl1 where eventDate>=GetDate()

    Reference: http://stackoverflow.com/questions/10643379/how-do-i-query-for-all-dates-greater-than-a-certain-date-in-sql-server

  • #768705
    Hi,

    If you want to filter the table based on time then please refer below sample and remodify as per your need,


    select * from tablename where cast(datecolumn as time) between '10:00' and '13:00'


    Try something like above

    --------------------------------------------------------------------------------
    Give respect to your work, Instead of trying to impress your boss.

    N@veen
    Blog : http://naveens-dotnet.blogspot.in/


  • Sign In to post your comments