Reset datetime time with SQL

Asked

Viewed 2,352 times

4

Today, man SELECT returns the following date:

2017-11-16 10:37:16.000

I’d like you to return 2017-11-16 00:00:00.000, can help me with this formatting?

  • 1

    What is your database? Post your SQL command

  • I don’t know much about formatting, I’m using a normal select "SELECT DATA FROM TBL_DATAS"

  • what is your young database ? mysql, Firebird, sql-server, postgres ?

  • What is your database? You want to return hours or just date (yyyy-MM-dd) enough?

  • The database is Sql Server

  • I need you to return the second zeroes R. Santos

  • then use SELECT CURDATE() and take only the date, since you want the minutes, seconds and time reset, there will be no difference for you

  • 1

    @user90864 Any of the answers resolve your need? If yes just mark it as correct to help future people who may have the same difficulty finding the answer faster

Show 3 more comments

2 answers

3


You can use the format and spend the zeroed part of hours. Ex:

SELECT FORMAT(GETDATE(), 'yyyy-MM-dd 00:00:00') AS DATE;

0

Another option would be like this:

 SELECT to_char(DATA, 'yyyy-MM-dd 00:00:00.000') AS DATE from TBL_DATAS;

Browser other questions tagged

You are not signed in. Login or sign up in order to post.