Forum Discussion

runnerpaul's avatar
runnerpaul
Regular Visitor
10 years ago
Solved

Create Morning/Afternoon columns based on DateTime column

Hi,   I have a table with a datetime column called CREATEDDATETIME. I want to use it to create a new column where depending on the time it gets populated with Morning or Afternoon. Anything before ...
  • SamLester's avatar
    10 years ago

    Hi Paul, you can use the HOUR function in an IF statement to calculate this.

     

    Example:

    MorningAfternoon = if((HOUR(TimeTable[CREATEDDATETIME]) <= 12), "Morning", "Afternoon")

     

    Thanks,
    Sam Lester (MSFT)