SQL Converting Time to Half Hour Increments and Extracting only HH:MM -
i need show report counts sessions in half hour increments 24 hour period. used following case statement , works convert minutes in date field.
case when datepart (mi,"tablename.name") < 30 dateadd(hh, datediff(hh, 0, "tablename.name")+0, 0) else dateadd (mi, 30, dateadd(hh, datediff(hh, 0, "tablename.name")+0, 0)) end,
now having trouble pulling out hh:mm. tried this, gives me 2 additional columns.
datepart(hh,"tablename.name") 'start_hour', datepart(minute,"tablename.name") 'start_min'
try this:
cast(datepart(hour,"tablename.name") char(2)) + ':' + cast(datepart(minute,"tablename.name") char(2)) start_time
Comments
Post a Comment