• Resolved miami44

    (@miami44)


    hey, i am using the template of your pregancy calculator but i want to add the current pregancy week and i am facing two problems..

    Fieldname1 (is day of last period)

    fieldname11 the current date (GETDATETIMESTRING(NOW(), ‘dd/mm/yyyy hh:ii’);)

    Then i have fieldname7 (output)

    ROUND(ABS(fieldname1-fieldname11)/7) It kinda works but i would need always need to round down .. is there an option for this?

    Or best Option would even be to show like current week + days but i am not sure how i could make an output like this.

    Also i want to get ride of filedanme 11 and would like to use the current day in the calculation

    but

    ROUND(ABS(fieldname1-GETDATETIMESTRING(NOW(), ‘dd/mm/yyyy hh:ii’))/7 or ROUND(ABS(fieldname1-NOW())/7) is not working i am not sure how the date field are calculated or how is the best way to do math work with them .. maybe someone have an example how to work best with dates.

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author codepeople

    (@codepeople)

    Hello @miami44

    The plugin includes multiple rounding operations:

    ROUND rounds the parameter to the nearest integer number by default.
    FLOOR rounds down the nearest integer number by default.
    CEIL rounds up the nearest integer number by default.

    To get the current day for calculation, you should use the TODAY() or NOW() operations. But in this case, you must use the DATEDIFF operation instead of subtracting the values directly because TODAY() and NOW() return date objects:

    FLOOR(DATEDIFF(fieldname1, TODAY(), 'mm/dd/yyyy', 'd')['days']/7)

    And responding to your other question. If you need the current year week number, you can use the WEEKNUM() operation passing TODAY() as its parameter:

    WEEKNUM(TODAY())

    Learn more about the Date/ Times operations module by reading the following section in the plugin documentation:

    https://cff.dwbooster.com/documentation#datetime-module

    Best regards.

    Thread Starter miami44

    (@miami44)

    thanks a lot for this super fast reply. I think Datediff is only availibe for premium..

    So for now i used FLOOR(ABS((fieldname1-fieldname11)/7)) , that works great for me ! Thanks agaoin

    Plugin Author codepeople

    (@codepeople)

    Hello @miami44,

    The Date/Time operations module is available in every plugin distribution (including the free one), but Javascript is a case-sensitive language. The operation’s name is DATEDIFF.

    Best regards.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘pregancy caluclator additonal’ is closed to new replies.