0

2019-09-05 23:07:16.643 I want to get 2019-09-05 & 23:07:16.643 separately.

SHAH NEWAZ
  • 11
  • 2
  • 1
    Please provide what you have tried so far. Also, if this is just about SQL, why is the question tagged C#? Will C# solutions be okay with you? – 41686d6564 stands w. Palestine Sep 05 '19 at 17:10
  • Possible duplicate of [How to return only the Date from a SQL Server DateTime datatype](https://stackoverflow.com/questions/113045/how-to-return-only-the-date-from-a-sql-server-datetime-datatype) – Jota.Toledo Sep 05 '19 at 17:15
  • sry for the mistake. This is my first question in this platform, I want to solve this in SQL. – SHAH NEWAZ Sep 05 '19 at 17:16
  • Which [DBMS](https://en.wikipedia.org/wiki/DBMS) product are you using? "SQL" is just a query language, not the name of a specific database product. Please [add a tag](https://meta.stackoverflow.com/questions/388759/why-should-i-tag-my-rdbms) for the database product you are using `postgresql`, `oracle`, `sql-server`, `db2`, ... –  Sep 05 '19 at 17:18

2 Answers2

1

You can see this link Convert datetime in sql and use the conversation format of your preference.

something like this in sql

select convert(varchar, getdate(), 111) as OnlyDate, convert(varchar, getdate(), 8) as OnlyTime

for c#

var date = DateTime.Now.Date; //get only date
var time = DateTime.Now.TimeOfDay; //get only time 
0

As by the assumption that database is not known can try to manipulate datetime by splitting it before and after space.

   Select SUBSTR(datetime,1, 
      Instr(datetime, ' ')) as date,
    Substr(datetime, Instr(datetime, ' ')+1, 
      length(datetime)) as time from table
Himanshu
  • 3,830
  • 2
  • 10
  • 29