-2

I have a field that stores the date and time but need to extract this so it only shows the time but shows the date as 01/01/1900.

I can extract the time using the below but need to include the data of 01/01/1900

convert(varchar(12), w.created, 114)
Paul Roub
  • 36,322
  • 27
  • 84
  • 93
Raehef
  • 1
  • 1

1 Answers1

1

If you are using SQL Server, then you can do:

select cast('1900-01-01' as datetime) + cast(cast(w.created as time) as datetime)

This returns the value as a datetime.

SQL Server has a time data type. It is unclear why you would want to add in a fake date, but you can.

Gordon Linoff
  • 1,242,037
  • 58
  • 646
  • 786