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

    How get data from Today date time and From Next Date time in sql server

    Hi,
    I want a fetch data From date time (10/04/2017 and time 07:30:00 am)
    And Next Date time (11/04/2017 and time 07:29:59 am)
    with using where clause in SQL server. Because of Stat are working
    shift wise work.

    Data:

    ABC 10/04/2017 07:30:00.00000
    XYZ 10/04/2017 07:35:00.00000
    ZDY 11/04/2017 07:20:59.00000
    SDY 11/04/2017 07:29:59.00000
  • #769176
    Hi,

    We can get the value in SQL Query,


    SELECT ...
    FROM table_name
    WHERE shift_date >= TO_DATE('2017-04-10', 'YYYY-MM-DD')
    AND shift_date < TO_DATE('2017-04-11', 'YYYY-MM-DD')

    Thanks,
    Mani

  • #769187
    You can use given code snippet to get data from Today date time and From Next Date time in sql server
     SELECT Column1,Column2,Column3 FROM TABLENAME WHERE Column3 BETWEEN GetDate()-1 AND GetDate()
    Or
    SELECT * FROM #temp WHERE CONVERT(VARCHAR(10),CrDate,103) BETWEEN CONVERT(VARCHAR(10),'07/04/2017',103) AND CONVERT(VARCHAR(10),'10/04/2017',103)


Sign In to post your comments