You must Sign In to post a response.

how will i get time using SQL query?

i hav a datetime field in a table. if i select the field, it shows both date with time. but i want to show only the time?

how will i get time using SQL query?


Comments

Author: Rajaraman09 Oct 2006 Member Level: Gold   Points : 2

select convert(varchar,getdate(),108)

Author: Rajaraman09 Oct 2006 Member Level: Gold   Points : 2

select convert(varchar,getdate(),108)

Author: Rajaraman09 Oct 2006 Member Level: Gold   Points : 2

select convert(varchar,getdate(),108)

Author: Vadivel Mohanakrishnan09 Oct 2006 Member Level: Gold   Points : 2

Yes ppl have already answered. Just go through the Convert function and choose appropriate number as per ur desired format. GetDate() is the function to print the current datetime.

Author: madhavi reddy09 Oct 2006 Member Level: Silver   Points : 2

hi,
yes.GetDate() is the function to display datetime

Author: S.V.Sirish10 Oct 2006 Member Level: Silver   Points : 2

Hello,

I think the below query should work

Select Convert(varchar,DatePart(HH,WH)) + ':' + Convert(varchar,DatePart(MI,WH)) + ':' + Convert(varchar,DatePArt(SS,WH)) from WorkingHours

Replace WH and WorkingHours with your fieldname and Tablename

- Sirish

Author: Mohit Chawla10 Oct 2006 Member Level: Silver   Points : 2

use getdate() which will fetch you the date and time and then convert it into the time format i.e. 108 format.

Convert(varchar, getdate(),108)

Author: Ravindra R10 Oct 2006 Member Level: Gold   Points : 2


Convert(varchar, getdate(),108)


Sign In to post your comments