3

I need to create a calculated column -say ResCount - based on another datetimefield field, ie,assuming if mydt is my datetimefield, from this field, I need to extract month part and based on month name,I need to assign a number for ResCount.

For example, if its Jan, then ResCount value would be 30 and if its Feb then the ResCount is 60 etc.

  • Is this possible using calculated column field? or
  • Should I use SPServices and jQuery to determine the selected month when a new item is added on presaveaction call ?

    4

    MONTH( [MyDate] ) will return 1 for January,
    then use the SharePoint version of the switch/case statement:

    =CHOOSE( MONTH([MyDate]) , 30 , 60 , 60 , 60 , 60 , 60 , 60 , 60 , 60 , 60 , 60 , 60 )
    

    remember: if you are going to work with Dates in JavaScript then January = 0 and December = 11

    All SharePoint functions: www.viewmaster365.com/functions

    Monthnames

    TEXT ( [MyDate] , "mmm" ) returns 'Jan'

    TEXT ( [MyDate] , "mmmm" ) returns 'January'

    • That's very helpful information! – SaMolPP Dec 14 '15 at 8:51
    • 1
      Then close your question, let's reduce that 19.344 open questions to 0 this year – Danny '365CSI' Engelman Dec 14 '15 at 8:53
    • Danny,thanks for the replies.I am having a chart web part and I need add this rescount as X-field in the chart.But am not able to see this calulcated column in the dropdown. Does the chart web part not support calculalated columns? – SaMolPP Dec 14 '15 at 11:17
    • I don't know.. have not used that WebPart for some years – Danny '365CSI' Engelman Dec 14 '15 at 12:45

    Your Answer

    By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

    Not the answer you're looking for? Browse other questions tagged or ask your own question.