Time returning just the hour

J

Jason

I have a short time field and I am trying to get the hour portion without the
minutes.
For 17:00 I would like to return 17 and for 07:00 return 07

I have tried the left function but that returns 7: for 7:00 (which makes
sense) but it also returns 5: for 17:00

Can anyone help me return the values before the semicolon. I would like to
end up with 07 and 17

Here is the SQL I have if it helps

SELECT Tbl_UnitHours.UHID, Tbl_UnitHours.ShiftAssignedTo,
Tbl_UnitHours.StartTime, Tbl_UnitHours.EndTime, "(" &
[Tbl_DayofWeek]![DayAbrv] & ")" & [Qry_Stations]![StationAbrv] & "(" &
[Qry_Units]![Unit Abrv] & ")" AS Shift, Left([Tbl_UnitHours]![StartTime],2)
AS Expr1
FROM ((Tbl_UnitHours INNER JOIN Tbl_DayofWeek ON Tbl_UnitHours.DayofWeek =
Tbl_DayofWeek.DayID) INNER JOIN Qry_Stations ON Tbl_UnitHours.Station =
Qry_Stations.StationID) INNER JOIN Qry_Units ON Tbl_UnitHours.Unit =
Qry_Units.UnitID;
 
J

Jason

That got it thank you

KARL DEWEY said:
Try this --
Format([Tbl_UnitHours]![StartTime],"hh") AS Expr1

--
KARL DEWEY
Build a little - Test a little


Jason said:
I have a short time field and I am trying to get the hour portion without the
minutes.
For 17:00 I would like to return 17 and for 07:00 return 07

I have tried the left function but that returns 7: for 7:00 (which makes
sense) but it also returns 5: for 17:00

Can anyone help me return the values before the semicolon. I would like to
end up with 07 and 17

Here is the SQL I have if it helps

SELECT Tbl_UnitHours.UHID, Tbl_UnitHours.ShiftAssignedTo,
Tbl_UnitHours.StartTime, Tbl_UnitHours.EndTime, "(" &
[Tbl_DayofWeek]![DayAbrv] & ")" & [Qry_Stations]![StationAbrv] & "(" &
[Qry_Units]![Unit Abrv] & ")" AS Shift, Left([Tbl_UnitHours]![StartTime],2)
AS Expr1
FROM ((Tbl_UnitHours INNER JOIN Tbl_DayofWeek ON Tbl_UnitHours.DayofWeek =
Tbl_DayofWeek.DayID) INNER JOIN Qry_Stations ON Tbl_UnitHours.Station =
Qry_Stations.StationID) INNER JOIN Qry_Units ON Tbl_UnitHours.Unit =
Qry_Units.UnitID;
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top