Hi KeSue,
Build your function is two steps.
Add a column (D in the example) into which you will import the "a.m." values, and place a null string into the cells on rows with "p.m." values, using an IF statement.
Use STDEV or STDEVP to determine the standard deviation in this column.
In the example, I've used RANDBETWEEN to generate a set of random numbers in column D. I then, to check the effect of a half empty column on the results, copied half that list and used Paste Formula Results to paste the same set of 10 numbers into the upper (AM) and lower (PM) halves of the column.
As can be seen at the bottom, the STDEVP result is the same for the double set (column C as it is for the single set (and 10 cells containing null strings) in column D. The function does not count the null string values in the 'empty' half of the day.

Formulas:
D2, and filled down to D21: IF(B2=D$23,C2,"")
D23 contains the text to be matched in column B for the value in that row of column C t be copied to the same row of column D.
D22: STDEVP(D)
The same formula, with C in the parentheses, is in C22, but is not needed in your table.
Lookup STDEV in the Function Browser for details on the differences between STDEV, STDEVP (used here), STDEVA and STDEVPA. All four perform the same job, but with different parameters, one of which shuld fit your case.
Regards,
Barry